Introduction
Another article for solving an error message occur when running a docker-compose command. Actually, the error message appear when the execution of the docker-compose command is focusing on the build process. So, using the additional command parameter of ‘build’, the build process stop and generating an error message. That error message exist as follows :
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount168170023/Dockerfile: no such file or directory ERROR: Service 'db' failed to build : Build failed
Furthermore, the process itself exist in a device using a Microsoft Windows operating system. So, there is a docker-compose.yml file exist in a certain folder. After executing the ‘docker-compose build’ command in the Command Prompt at that certain folder’s path, it ends in an error message. The following is the actual execution process :
C:\repository\docker\wordpress>docker-compose build Building db [+] Building 0.1s (2/2) FINISHED => [internal] load build definition from Dockerfile 0.1s => => transferring dockerfile: 2B 0.0s => [internal] load .dockerignore 0.1s => => transferring context: 2B 0.0s failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount168170023/Dockerfile: no such file or directory ERROR: Service 'db' failed to build : Build failed C:\repository\docker\wordpress>
For a reference, the following is the content of the docker-compose.yml :
version: '3.3' services: db: build: build/ image: mysql:5.7 container_name: db volumes: - db_data:"C:\\repository\\docker\\wordpress\\data" restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: build: build/ container_name: wordpress depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpress volumes: db_data: {}
Below, for more information is the structure of the directory where the ‘docker-compose.yml’ file exist :
C:\repository\docker\wordpress>dir Volume in drive C is Windows-SSD Volume Serial Number is CA30-19A4 Directory of C:\repository\docker\wordpress 05/29/2022 12:20 AM <DIR> . 05/25/2022 01:27 PM <DIR> .. 05/29/2022 12:30 AM <DIR> build 05/20/2022 02:41 PM <DIR> data 05/29/2022 12:20 AM 741 docker-compose.yml 3 File(s) 757 bytes 4 Dir(s) 181,848,289,280 bytes free C:\repository\docker\wordpress> cd build C:\repository\docker\wordpress\build>dir Volume in drive C is Windows-SSD Volume Serial Number is CA30-19A4 Directory of C:\repository\docker\wordpress\build 05/29/2022 12:30 AM <DIR> . 05/29/2022 12:20 AM <DIR> .. 1 File(s) 30 bytes 2 Dir(s) 181,832,093,696 bytes free C:\repository\docker\wordpress\build>
How to Solve Error Message failed to solve with frontend dockerfile.v0: failed to read dockerfile: no such file or directory
The error message in the above exist because of the Dockerfile is not available. So, why does the docker-compose command need an additional Dockerfile ?. Isn’t it just enough to use only a docker-compose.yml ?. Well, the answer is because of the additional configuration definition in the docker-compose.yml as follows :
build: build/
So, the above definition is a configuration to tell the docker-compose command a specific information. In other words, in the image building process, look at the build folder. Inside the build folder, since the build process need a Dockerfile, it will look for one. Unfortunately, in the current status, that file is not exist. So, the solution is very simple. Just create a Dockerfile inside the ‘build/’ folder. In the end, the content inside the ‘build’ folder will be as follows :
C:\repository\docker\wordpress\build>dir Volume in drive C is Windows-SSD Volume Serial Number is CA30-19A4 Directory of C:\repository\docker\wordpress\build 05/29/2022 12:30 AM <DIR> . 05/29/2022 12:20 AM <DIR> .. 05/29/2022 06:33 AM 30 Dockerfile 1 File(s) 30 bytes 2 Dir(s) 181,832,093,696 bytes free C:\repository\docker\wordpress\build>
After creating a Dockerfile file, just run the ‘docker-compose build’ again once more.
One thought on “How to Solve Error Message failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount168170023/Dockerfile: no such file or directory when running docker-compose command in Microsoft Windows”