Can you make any sense of Dockers error-messages?

Viewed 20275

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
5 Answers

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.

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.

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.

I had the same issue but a different solution (on Windows):

  • I opened a console in my folder; my folder contains only Dockerfile
  • Dockerfile content was FROM ubuntu:20.04 (same as OP)
  • Ran docker build knowing that I had a Dockerfile in my current folder
  • I was getting the OP's same error message
  • I stopped the Docker Desktop service
  • Ran docker build again -- got "docker build" requires exactly 1 argument.
  • Ran docker build Dockerfile -- got unable to prepare context: context must be a directory: C:\z\docker\aem_ubuntu20\Dockerfile
  • Ran docker build . -- got error 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, where PATH must be a folder name and that folder must contain a Dockerfile

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.

Related