Docker: unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx
Solution 1
while executing following command:
docker build -t docker-whale .
check that Dockerfile is present in your current working directory.
Solution 2
The error message is misleading. The problem has nothing to do with symlinks really. It is usually only that docker cannot find the Dockerfile describing the build.
Typical reasons are these:
- Dockerfile has wrong name.
It must be calledDockerfile
. If it is called, for instance,dockerfile
,.Dockerfile
,Dockerfile.txt
, or other, it will not be found. - Dockerfile is not in context.
If you saydocker build contextdir
, the Dockerfile must be atcontextdir/Dockerfile
. If you have it in, say,./Dockerfile
instead, it will not be found. - Dockerfile does not exist at all.
Sounds silly? Well, I got the above error message from my GitLab CI after I had written a nice Dockerfile, but forgotten to check it in. Silly? Sure. Unlikely? No.
Solution 3
If you are working on windows 8 you would be using Docker toolbox. From the mydockerbuild directory run the below command as your Dockerfile is a textfile
docker build -t docker-whale -f ./Dockerfile.txt .
Solution 4
The name of the file should be Dockerfile
and not .Dockerfile
. The file should not have any extension.
Solution 5
- Make sure you moved to the directory where Dockerfile is located.
- Make sure your Dockerfile is extension-less. That is, not Dockerfile.txt, Dockerfile.rtf, or any other.
- Make sure you named Dockerfile, and not DockerFile, dockerfile or any other.
Related videos on Youtube

villanux
Updated on September 28, 2021Comments
-
villanux about 1 year
I just downloaded Docker Toolbox for Windows 10 64bit today. I'm going through the tutorial. I'm receving the following error when trying to build an image using a Dockerfile.
Steps:
- Launched Docker Quickstart terminal.
- testdocker after creating it.
- Prepare Dockerfile as documented in "Build your own image" web link
- ran below command
docker build -t docker-whale .
Error: $ docker build -t docker-whale .
unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx C:\Users\Villanueva\Test\testdocker\Dockerfile: The system cannot find the file specified.
BTW: I tried several options mentioned @ https://github.com/docker/docker/issues/14339
$ docker info Containers: 4 Running: 0 Paused: 0 Stopped: 4 Images: 2 Server Version: 1.10.1 Storage Driver: aufs Root Dir: /mnt/sda1/var/lib/docker/aufs Backing Filesystem: extfs Dirs: 20 Dirperm1 Supported: true Execution Driver: native-0.2 Logging Driver: json-file Plugins: Volume: local Network: bridge null host Kernel Version: 4.1.17-boot2docker Operating System: Boot2Docker 1.10.1 (TCL 6.4.1); master : b03e158 - Thu Feb 11 22:34:01 UTC 2016 OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 996.2 MiB Name: default ID: C7DS:CIAJ:FTSN:PCGD:ZW25:MQNG:H3HK:KRJL:G6FC:VPRW:SEWW:KP7B Debug mode (server): true File Descriptors: 32 Goroutines: 44 System Time: 2016-02-19T17:37:37.706076803Z EventsListeners: 0 Init SHA1: Init Path: /usr/local/bin/docker Docker Root Dir: /mnt/sda1/var/lib/docker Labels: provider=virtualbox
-
villanux almost 7 yearsUpdate: docker build -t XXX --file ./Dockefile . worked. Docker may want to update their documentation for Windows users.
-
eXa over 6 yearsIf
docker build -t XXX --file ./Dockefile
it might be because you got the filename wrong it's missing the R. -
RichVel almost 6 yearsThis is an amazingly bad error message, it just means "cannot open file" - same on Linux and macOS.
-
lmat - Reinstate Monica over 2 yearsMind-blowingly bad error message.
-
IanGSY about 6 yearsThanks. My issue was I had created my Dockerfile in Notepad and it had automatically appended .txt to the filename.
-
Sumi Straessle almost 6 yearsYou may also explicitly write the Dockerfile name with the
f
flag, as indocker build -f Dockerfile-dev.yaml -t my_container .
This may prove useful if you have several Dockerfile in your project, one per environment, for example. The same applies to docker-compose. Putting them in different subdirectories will not work, since the context (.
) will not match. -
sebagomez over 5 yearsnot anymore (if ever)
docker build -t docker-whale .
is a valid command -
K. Brafford about 5 years@IanGSY I wish I could give you more points for that. That was exactly my problem too!
-
Alex almost 5 yearsfor future reference if you need to do this it is because your Dockerfile has an extension whereas by default Docker expects it not too. Setting the file manually with the extension adds headaches you do not need. You should set Windows explorer to show extensions and then remove the extension.
-
Per Lundberg almost 5 yearsNotepad is an excessively evil program.
-
Mike Kellogg almost 5 yearsif you're following along on the docker documentation "getting started" tutorial you would use this:
docker build -t friendlyhello -f ./Dockerfile.txt .
-
myloginid over 4 yearsIts really bad semantics that you have to specify the file name and the dummy path also. and/or always name your file as Dockerfile.. :-(
-
Lawrence Lee almost 4 yearsThis worked for me! I only installed Docker Toolbox and didn't install it in WSL; instead, I'm using the windows executables directly, since WSL can do that now.
-
Sachidananda Naik about 3 yearsThis saved my day. By the way, I'm using a Mac machine. But the catch here is that the Dockerfile was created a plain text file. Thanks buddy for the help.
-
Paul Gear about 3 yearsI think this would be a lot stronger (and more relevant) an answer without the 2nd half.
-
leon.io about 3 yearsGreat answer, and thanks for the background information
-
Donald Shahini about 3 yearsDockerfile is not a .txt file. If you have it as a .txt file it will give error again.
-
Purplejacket over 2 yearsIt's also necessary to have the
.
(dot) at the end of the line, as the above shows. -
Purplejacket over 2 yearsDocumentation for
docker build
is here: docs.docker.com/engine/reference/commandline/build -
Ayyappa over 2 yearsI cloned a json file instead of creating a new file. Once i renamed it to Dockerfile and updated it contents, it didn't show .json extension and later realised thats the culprit! Thanks for the note!
-
Junaid about 2 yearsFilename did the trick for me. I had to change DockerFile to
Dockerfile
-
Saites almost 2 yearsLikewise, check for simple spelling errors. I landed here because
Dockefile
is certainly not the same asDockerfile
:facepalm: Since building withdocker build -f <tab-completed filename> .
worked, I looked closer and realized I had mistyped it. -
Kraken almost 2 yearsWhen you need a reminder that you're calling from the wrong directory xD
-
Christopher Markieta almost 2 yearsCopied something weird after the trailing period, removing this helped.
-
Ukrainian-serge 8 monthsbig help on the
Dockerfile
instead ofDockerFile