MBaas
MBaas

Reputation: 7530

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

Upvotes: 23

Views: 49065

Answers (7)

user22703153
user22703153

Reputation: 1

You should run docker build -t +name .

Upvotes: 0

tishma
tishma

Reputation: 1885

In my case I got this error when running docker commands in a wrong directory. Just cd to the dir where your Dockerfile is, and all is good again.

Upvotes: 1

user1872177
user1872177

Reputation: 113

First check Docker file name(D should be capital), then run docker build -f Dockerfile . (dot at the end).

Upvotes: 4

rob_7cc
rob_7cc

Reputation: 917

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

Upvotes: 3

Guilherme Ferreira
Guilherme Ferreira

Reputation: 459

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.

Upvotes: 1

Shreekanth Gaanji
Shreekanth Gaanji

Reputation: 668

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.

Upvotes: 6

ozs
ozs

Reputation: 3681

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.

Upvotes: 46

Related Questions