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

Viewed 1825

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

4 Answers

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).

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.

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 :-)

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.

Related