Reputation: 1619
I am new to Docker and i am trying to create an image from my application, i created Dockerfile
in the same directory with package.json
file with no extension, just Dockerfile
Now in Dockerfile
:
FROM node:14.16.0
CMD ["/bin/bash"]
and i am trying to build the image with that command
docker build -t app .
But i got this constant error:
[+] Building 0.2s (2/2) FINISHED
=> [internal] load build definition from Dockerfile 0.2s
=> => transferring dockerfile: 2B 0.0s
=> CANCELED [internal] load .dockerignore 0.0s
=> => transferring context: 0.0s
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount457647683/Dockerfile: no such file or directory
My folder directory is like this:
|- Dockerfile
|- README.md
|- src
|- package.json
|- public
|- node-modules
|-package-lock.json
My OS is : Windows 10 Pro
Upvotes: 20
Views: 32597
Reputation: 11
In my case, the error was that the Dockerfile location was incorrect so I correct the location and it worked
Upvotes: 0
Reputation: 54
It's a pretty generic error message but what caused it for me, was in my Dockerfile, I didn't have a space specifying the initial command properly. Here's how it should look like:
CMD ["command-name"]
Notice the space between "CMD" and "[".
Instead, my mistake was that I typed CMD["command-name"]
which resulted in the error you described.
Upvotes: 1
Reputation: 119
Naming convention for Docker file is 'Dockerfile' not 'DockerFile', I got this error because of this.
Upvotes: 5
Reputation: 189789
If you come here from a duplicate, notice also that Docker prevents you from accessing files outside the current directory tree. So, for example,
docker build -f ../Dockerfile .
will not be allowed. You have to copy the Dockerfile into the current directory, or perhaps run the build in the parent directory.
For what it's worth, you also can't use symlinks to files elsewhere in your file system from docker build
for security reasons.
Upvotes: 6
Reputation: 347
I encountered a different issue, so sharing as an FYI. On Windows, I created the docker file as DockerFile
instead of Dockerfile
. The capital F
messed things up.
Upvotes: 23
Reputation: 9
In windows when the Dockerfile is in .txt format I got this error. changing it to type "file" fixed the issue.
Upvotes: 0
Reputation: 191
Double check that you are in the right directory. I was in downloads/app
When I downloaded the app from Docker as part of their tutorial, I extracted it and it ended up in downloads/app**/app**
Type dir
in your terminal to see if you can see dockerfile or another folder called app.
Upvotes: 19