Introduction
Another error appear where the process is running for building an image. That command is the ‘docker-compose build’ command. The following is the command execution for building the docker image :
(env) C:\docker\django>docker-compose build Building web unable to prepare context: Cannot locate Dockerfile: "\\\\?\\C:\\docker\\django\\hellodjango\\Dockerfile" ERROR: Service 'web' failed to build : Build failed (env) C:\docker\django>
On the execution of the ‘docker-compose build’ command, it will use the content definition from docker-compose.yml file. The following is the structure of the directory content :
C:\docker\django>tree . Folder PATH listing Volume Serial Number is FC64-E91F C:\docker\django │ .env.dev ├─ docker-compose.yml ├─ env ├─ hellodjango ├───── hellodjango └───── manage.py C:\docker\django>
Solution
Actually, the error has an already definite solution. It is because there is no file with the name of ‘Dockerfile’ in the directory structure where the ‘docker-compose’ file exist. So, add it in the ‘hellodjango’ folder where it can be exist as in the following output :
C:\docker\django>tree . Folder PATH listing Volume Serial Number is FC64-E91F C:\docker\django │ .env.dev ├─ docker-compose.yml ├─ env ├─ hellodjango ├───── Dockerfile ├───── hellodjango └───── manage.py C:\docker\django>
Before getting on to the execution of the command once more, the following is the content of the Dockerfile :
FROM --platform=linux/amd64 centos WORKDIR /usr/src/app ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 RUN yum -y install python3-pip RUN pip install --upgrade pip COPY ./requirements.txt /usr/src/app RUN pip install -r requirements.txt COPY . .
So, ffter adding the file with the name of ‘Dockerfile’ in the folder, just execute the command once more. The following is the execution of the command execution of the ‘docker-compose’ as follows :
C:\docker\django>docker-compose build Sending build context to Docker daemon 2.463kB Step 1/9 : FROM --platform=linux/amd64 centos ---> 5d0da3dc9764 Step 2/9 : WORKDIR /usr/src/app ---> Using cache ---> 8b8c8958c2c5 Step 3/9 : ENV PYTHONDONTWRITEBYTECODE 1 ---> Using cache ---> 7b3fe44e5621 Step 4/9 : ENV PYTHONUNBUFFERED 1 ---> Using cache ---> 64e9a28ec582 Step 5/9 : RUN yum -y install python3-pip ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (windows/amd64) and no specific platform was requested ---> Running in 4cadf0856d9f CentOS Linux 8 - AppStream 863 kB/s | 8.4 MB 00:10 CentOS Linux 8 - BaseOS 750 kB/s | 4.6 MB 00:06 CentOS Linux 8 - Extras 4.8 kB/s | 10 kB 00:02 Dependencies resolved. ================================================================================ Package Arch Version Repo Size ================================================================================ Installing: python3-pip noarch 9.0.3-20.el8 appstream 20 k Upgrading: chkconfig x86_64 1.19.1-1.el8 baseos 198 k Installing dependencies: platform-python-pip noarch 9.0.3-20.el8 baseos 1.7 M python3-setuptools noarch 39.2.0-6.el8 baseos 163 k python36 x86_64 3.6.8-38.module_el8.5.0+895+a459eca8 appstream 19 k Enabling module streams: python36 3.6 Transaction Summary ================================================================================ Install 4 Packages Upgrade 1 Package Total download size: 2.1 M Downloading Packages: (1/5): python36-3.6.8-38.module_el8.5.0+895+a45 19 kB/s | 19 kB 00:01 (2/5): python3-pip-9.0.3-20.el8.noarch.rpm 20 kB/s | 20 kB 00:01 (3/5): python3-setuptools-39.2.0-6.el8.noarch.r 426 kB/s | 163 kB 00:00 (4/5): chkconfig-1.19.1-1.el8.x86_64.rpm 471 kB/s | 198 kB 00:00 (5/5): platform-python-pip-9.0.3-20.el8.noarch. 642 kB/s | 1.7 MB 00:02 -------------------------------------------------------------------------------- Total 567 kB/s | 2.1 MB 00:03 warning: /var/cache/dnf/appstream-02e86d1c976ab532/packages/python3-pip-9.0.3-20.el8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY CentOS Linux 8 - AppStream 1.6 MB/s | 1.6 kB 00:00 Importing GPG key 0x8483C65D: Userid : "CentOS (CentOS Official Signing Key) <security@centos.org>" Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Upgrading : chkconfig-1.19.1-1.el8.x86_64 1/6 Installing : python3-setuptools-39.2.0-6.el8.noarch 2/6 Installing : platform-python-pip-9.0.3-20.el8.noarch 3/6 Installing : python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 4/6 Running scriptlet: python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 4/6 Installing : python3-pip-9.0.3-20.el8.noarch 5/6 Cleanup : chkconfig-1.13-2.el8.x86_64 6/6 Running scriptlet: chkconfig-1.13-2.el8.x86_64 6/6 Verifying : python3-pip-9.0.3-20.el8.noarch 1/6 Verifying : python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 2/6 Verifying : platform-python-pip-9.0.3-20.el8.noarch 3/6 Verifying : python3-setuptools-39.2.0-6.el8.noarch 4/6 Verifying : chkconfig-1.19.1-1.el8.x86_64 5/6 Verifying : chkconfig-1.13-2.el8.x86_64 6/6 Upgraded: chkconfig-1.19.1-1.el8.x86_64 Installed: platform-python-pip-9.0.3-20.el8.noarch python3-pip-9.0.3-20.el8.noarch python3-setuptools-39.2.0-6.el8.noarch python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 Complete! 1 error occurred: * Status: The command '/bin/sh -c yum -y install python3-pip' returned a non-zero code: 4294967295: failed to shutdown container: container 4cadf0856d9fb2379f01fa675ca188f77f2974137fbedfdbdecc02e2308aea65 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110): subsequent terminate failed container 4cadf0856d9fb2379f01fa675ca188f77f2974137fbedfdbdecc02e2308aea65 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110), Code: 4294967295 C:\docker\django>
Finally, the process of the above command execution for once more is a success.