I am pretty new to Docker and trying to build docker image with plain html but i have this error message, saying failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount602954594/Dockerfile: no such file or directory
My folder directory is like this
C:\Users\hailey\Desktop\GitTest
|- Dockerfile.txt
|- README.md
|- testHelloWorld.html
Inside of the Dockerfile, I have
FROM ubuntu
WORKDIR C/Users/hailey/Desktop/GitTest
COPY testHelloWorld.html .
EXPOSE 8080
CMD ["html","testHelloWorld.html"]
I did my command docker build . inside of the directory C:\Users\hailey\Desktop\GitTest. then got
[+] Building 0.1s (2/2) FINISHED
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 2B
=> [internal] load .dockerignore
=> => transferring context: 2B
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount602954594/Dockerfile: no such file or directory
Does anyone have any other what I did wrong?
For those who use docker-compose build
also make sure you have properly set build
path in docker-compose.yml
:
version: '3.8'
services:
web:
build: ./services/web/ --> this folder should contain your Dockerfile, otherwise you will have the above error
Make sure you are in the correct directory first, and docker desktop is running.
I got the same error: It could be anything. Mine wasn't anything specific.. I had incorrectly named and referenced one of the files in the configs so when trying to run build it could not find that file.
It had nothing to do with frontend dockerfile.v0
(totally different file), check all your file are name and referenced correctly.
The issue in my case was, file name was correct but the extension was txt
.
What I did is , opened notepad++ and pasted this FROM mcr.microsoft.com/dotnet/aspnet:3.1
line and after that saved that file from notepad++ like below
once the file is saved it will look like below
One can provide the filename of the docker file using -f
.
For instance, if your docker file is called Dockerfile.base
, call the build
command as follows:
docker build . -f Dockerfile.base -t helloworld
Then, you can start the build image using following command:
docker run --rm -it helloworld
Try to set those .envs before executing your build/docker composer:
export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0
The name of docker files has no extension, it's just Dockerfile
with capital D
and lowercase f
You can also specify the Dockerfile name such as docker build . -f Dockerfile.txt
if you'd like to name it something else
I ran into similar issue while building a Visual Studio 2019 generated docker file.
>>failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount037306220/dockerfile: no such file or directory
Essentially the docker file is being referred from within the Windows Subsystem for Linux ( WSL). The tool mounted my local file system and is accessing the docker file in context of WSL. As file names are case sensitive on Linux, the docker command faithfully reported the error:
>> dockerfile: no such file or directory
Renaming the Dockerfile to "dockerfile" resolved the issue.
I had the same issue running "docker build -t getting-started ." from Visual Studio Code terminal.
But when I've executed the same command in CMD(Windows 10) it worked with no problems.
I would like to sum up the information from different answers in one answer, and also add my own experience that brought me to this question:
ls
or dir
depending on if you're using Linux or Windows/cmd shell respectively to determine if the file you'll use to build your docker container exists there)dockerfile
and Dockerfile
. If you have other capitals in the filename it will most likely fail. Also note that the default filenames have no file extension (so if you're to create the file in Notepad for instance, it may be a .txt or another extension by default). There is another answer here that shows how to save it without a filename from notepad, but you can also use the following commands in Linux and Windows command prompt, respectively:mv dockerfile.txt dockerfile
ren dockerfile.txt dockerfile
dockerfile
/Dockerfile
, then you can use the option -f
(link to docs), which states:-f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile')
Taken from another answer, here's an example of how you can use that command:
docker build . -f Dockerfile.base -t helloworld
And just to bring it all together, you don't need to use the filename again once the container is built, so you can just run it with:
docker run --rm -it helloworld
I just this same issue, turned out I had to place the docker file in right folder--the root project folder.
I had the same issue Working with react app. I had to move the Dockerfile from src to the project root folder and restarted docker desktop...it worked.
Make sure you see the list using "ls" or "dir" command.
In my case I create Dockerfile using Mac's Textedit and it had a hidden .rtf extension.
After removing the extension it worked.
Check the name of Dockerfile it should be "Dockerfile"