Search code examples
gitdockerdocker-build

Docker build on github branch cannot find file specified


I'm attempting to build a Docker image on Windows 10 using the following command:

docker build -t cron_runner .

I however get the following error:

unable to prepare context: unable to evaluate symlinks in context path: readlink C:\Users\xxx\Tools\Internal_Tools: The system cannot find the file specified.

The folder has a standard Dockerfile in it with no extension. The folder however is on a git branch that isn't master.

If I move the Dockerfile out of the Git folder into a local folder the docker image builds without any issues so I think the issue is to do with the fact its on a branch so there is a symlink issue.


Solution

  • when you run docker build; docker copies your context; which is the whole directory where your Dockerfile lives in (except when you use .dockerignore).

    It seems like a (broken?) symlink resides in the directory where your Dockerfile is; so either clean up the parent directory; either move the Dockerfile into a clean subdirectory.