Search code examples
dockerdocker-builddocker-desktop

Docker build with custom path and custom filename not working


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.


Solution

  • 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'