'Can you make any sense of Dockers error-messages?
I admit, I am a newbie in the container-world. But I managed to get docker running on my W10 with WSL2. I can also use the docker-UI and run Containers/Apps or Images. So I believe that the infrastructure is in place and uptodate. Yet, when I try even the simplest Dockerfile, it doesn't seem to work and I don't understand the error-messages it gives: This is Dockerfile:
FROM ubuntu:20.04
(yes, a humble beginning - or an extremly slimmed down repro)
docker build Dockerfile
[+] Building 0.0s (2/2) FINISHED
=> ERROR [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 33B 0.0s
=> ERROR [internal] load .dockerignore 0.0s
=> => transferring context: 33B 0.0s
------
> [internal] load build definition from Dockerfile:
------
------
> [internal] load .dockerignore:
------
failed to solve with frontend dockerfile.v0: failed to build LLB: error from sender: Dockerfile is not a directory
Solution 1:[1]
You need to run docker build -f [docker_file_name] . (don't miss the dot at the end).
If the name of your file is Dockerfile then you don't need the -f and the filename.
Solution 2:[2]
I faced a similar issue, I use the docker desktop for windows. Restarted the laptop and the issue was resolved. Hope it may help someone.
Solution 3:[3]
For me, I had a Linux symlink in the same directory as the Dockerfile. When running docker build from Windows 10, it gave me the ERROR [internal] load build definition from Dockerfile. I suspect Docker docker build . scans the directory and, if it can't read one file, it crashes. For me, I mounted the directory with WSL and removed the symblink.
Solution 4:[4]
I had the same issue but a different solution (on Windows):
- I opened a console in my folder; my folder contains only
Dockerfile Dockerfilecontent wasFROM ubuntu:20.04(same as OP)- Ran
docker buildknowing that I had aDockerfilein my current folder - I was getting the OP's same error message
- I stopped the Docker Desktop service
- Ran
docker buildagain -- got"docker build" requires exactly 1 argument. - Ran
docker build Dockerfile-- gotunable to prepare context: context must be a directory: C:\z\docker\aem_ubuntu20\Dockerfile - Ran
docker build .-- goterror during connect: This error may indicate that the docker daemon is not running. - Re-started the Docker Desktop service
- Ran
docker build .-- success! - Conclusion:
docker build PATH, wherePATHmust be a folder name and that folder must contain aDockerfile
Solution 5:[5]
In my case I got this error when running docker commands a wrong directory. Just cd to the dir where your Dockerfile is, and all is good again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | upe |
| Solution 2 | Shreekanth Gaanji |
| Solution 3 | Guilherme Ferreira |
| Solution 4 | rob_7cc |
| Solution 5 | tishma |
