olivedevelop
olivedevelop

Reputation: 91

I Can't build my docker file to create my docker image using Docker build

When I try to build my docker file, docker return the following error:

[+] Building 0.0s (1/2)                                                                                                                                                                                                                                       
 => ERROR [internal] load build definition from Dockerfile                                                                                                                                                                                               0.0s
 => => transferring dockerfile: 36B                                                                                                                                                                                                                      0.0s
------
 > [internal] load build definition from Dockerfile:
------
failed to solve with frontend dockerfile.v0: failed to read dockerfile: error from sender: walk Dockerfile: not a directory

Does anyone know how to solve this issue?
Thank you in advance

Upvotes: 8

Views: 4354

Answers (5)

Konrad Rudolph
Konrad Rudolph

Reputation: 545488

This error occurs when you invoke docker build and pass your Dockerfile as an argument rather than a directory.

That is, you tried the following, wrong command:

docker build Dockerfile

Instead, you need to invoke the command as follows:

docker build .

(Substitute the correct directory name if you are not running the command in the same directory as the Dockerfile.)

Upvotes: 1

user2909992
user2909992

Reputation: 1

I went through this issue. Make sure the location of dockerfile has the permission to access the file system. Once I have given the permissions, I am able to over come this issue.

Upvotes: 0

Vince.Bdn
Vince.Bdn

Reputation: 1175

It's hard to be a 100% sure of how to guide you with the information provided, but it looks like you may have directly provided the file path instead of the folder path (you can read more in the doc):

# this is used to build a Dockerfile file inside directory /PATH/TO/FOLDER
docker build /PATH/TO/FOLDER

If you want to give the Dockerfile path instead of the folder path, you may need to do (again read the doc for more):

# this is used to build a Dockerfile file given its content
docker build - < /PATH/TO/FOLDER/Dockerfile

(note that there a more subtleties because in the first case you build with a context and not in the second, I let you read Docker's doc which is fairly good).

Upvotes: 2

Baron_Samedi
Baron_Samedi

Reputation: 565

I am getting the same error with docker version 20.10.5, Mac: Big Sur 11.2.3 (latest)

even with a basic image...

FROM nginx
CMD [ "sleep", "30000" ]

There was a certificate issue but brew update and brew upgrade --force worked for me. I hope this helps :-)

Upvotes: 0

This type of error is generally because the name of the Dockerfile is wrong. Check that the name is exactly "Dockerfile", with just the D in capital letter, and without extension file.

Upvotes: 1

Related Questions