Reputation: 55
I am using Docker version 19.03.2 in Windows 10.
I have a directory C:\docker_test
with files Dockerfile
and Dockerfile_test
. When I execute
PS C:\> docker build 'C:\docker_test'
in PowerShell, the image is built from Dockerfile
, just as expected. However, when I want to build an image from Dockerfile_test
like this
PS C:\> docker build -f Dockerfile_test 'C:\docker_test'
I get
unable to prepare context: unable to evaluate symlinks in Dockerfile path:
CreateFile C:\Dockerfile_test: The system cannot find the file specified.
I don't understand why Docker is looking for C:\Dockerfile_test
although I specified a build path.
Upvotes: 4
Views: 3077
Reputation: 4731
There is already an answer to the question but this is to detail a bit
From the docs
The docker build command builds an image from a Dockerfile and a context. The build’s context is the set of files at a specified location PATH or URL
With C:\docker_test
you speficied the context.
From the same docs
Traditionally, the Dockerfile is called Dockerfile and located in the root of the context. You use the
-f
flag with docker build to point to aDockerfile
anywhere in your file system.
Therefore if you specify the -f
flag docker will search for the given file. In your case you have a file without path therefore docker will search in the current directory.
To make it work use the command as suggested by @Arik
Upvotes: 1
Reputation: 6501
You should state the path (the context) of your Dockerfile, like so
PS C:\> docker build -f 'C:\docker_test\Dockerfile_test' 'C:\docker_test'
Upvotes: 3