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
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.
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.
In windows when the Dockerfile is in.txt format I got this error. changing it to type "file" fixed the issue.
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.
Naming convention for Docker file is 'Dockerfile' not 'DockerFile', I got this error because of this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.