'failed to solve with frontend dockerfile
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?
Solution 1:[1]
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
Solution 2:[2]
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:
- Ensure that you're in the same directory that contains your dockerfile as where you're running your command from (running
lsordirdepending 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) - Docker will accept at least two (maybe only two?) default names for dockerfiles:
dockerfileandDockerfile. 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 dockerfileren dockerfile.txt dockerfile - If you need to use a different name instead of the default
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
Solution 3:[3]
You really need to use buildkit? if not:
Try to set those .envs before executing your build/docker composer:
export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0
Solution 4:[4]
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
Solution 5:[5]
I just this same issue, turned out I had to place the docker file in right folder--the root project folder.
Solution 6:[6]
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.
Solution 7:[7]
Rename your Dockerfile.txt to just as this Dockerfile. Because the dockerfile has no extensions.
Solution 8:[8]
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
Solution 9:[9]
Apart from correcting the Dockerfile name, that error can also happen if you add an extra dot at the end
Solution 10:[10]
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.
Solution 11:[11]
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.
Solution 12:[12]
Make sure you are in the correct directory first, and docker desktop is running.
Solution 13:[13]
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.
Solution 14:[14]
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.
Solution 15:[15]
Check the name of Dockerfile it should be "Dockerfile"
Solution 16:[16]
Solution 17:[17]
Another issue I had with this error was around the location in which I was executing the command. It might be useful for some to run the command from the correct directory (where the Dockerfile resides) and include the appropriate naming convention when creating the docker file. Dockerfile.
Solution 18:[18]
As mentioned before... the issue for me was the Dockerfile name. I had DockerFile on accident.
Changing the name to Dockerfile with the lowercase f and re-running the build command fixed the issue for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow



