Docker: unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx

DockerDockerfileDocker ToolboxDocker Build

Docker Problem Overview


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

Docker Solutions


Solution 1 - Docker

while executing following command:

docker build -t docker-whale .

check that Dockerfile is present in your current working directory.

Solution 2 - Docker

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 called Dockerfile. If it is called, for instance, dockerfile, .Dockerfile, Dockerfile.txt, or other, it will not be found.
  • Dockerfile is not in context.
    If you say docker build contextdir, the Dockerfile must be at contextdir/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 - Docker

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 - Docker

The name of the file should be Dockerfile and not .Dockerfile. The file should not have any extension.

Solution 5 - Docker

  1. Make sure you moved to the directory where Dockerfile is located.
  2. Make sure your Dockerfile is extension-less. That is, not Dockerfile.txt, Dockerfile.rtf, or any other.
  3. Make sure you named Dockerfile, and not DockerFile, dockerfile or any other.

Solution 6 - Docker

I had named my file dockerfile instead of Dockerfile (capitalized), and once I changed that, it started processing my "Dockerfile".

Solution 7 - Docker

Just Remove the extension .txt from Dockerfile and run the command

docker build -t image-name 

It will work for sure.

Solution 8 - Docker

I have got this error (in MacBook) though I used correct command to create image,

docker build -t testimg .

Later I found that path is the problem. Just navigate to the correct path that contains docker file. Just double check your current working directory .Nothing to panic!

Solution 9 - Docker

That's just because Notepad add ".txt" at the end of Dockerfile

Solution 10 - Docker

I had created my DockerFile by VS2017 Docker Support tool and had the same error. After a while I realised I was not in the correct directory that contains the Dockerfile (~\source\repos\DockerWebApplication\). cd'ed to the correct file (~/source/repos/DockerWebApplication/DockerWebApplication) which was inside the project and successfully created the docker image.

Solution 11 - Docker

In WSL, there seems to be a problem with path conversion. The location of the Dockerfile in Ubuntu (where I'm running docker and where Dockerfile lives) is "/home/sxw455/App1", but neither of these commands worked:

$ pwd
/home/sxw455/App1
$ ll
total 4
drwxrwxrwx 0 sxw455 sxw455 4096 Dec 11 19:28 ./
drwxr-xr-x 0 sxw455 sxw455 4096 Dec 11 19:25 ../
-rwxrwxrwx 1 sxw455 sxw455  531 Dec 11 19:26 Dockerfile*
-rwxrwxrwx 1 sxw455 sxw455  666 Dec 11 19:28 app.py*
-rwxrwxrwx 1 sxw455 sxw455   12 Dec 11 19:27 requirements.txt*

$ docker build -t friendlyhello .
unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx C:\Windows\System32\Dockerfile: The system cannot find the file specified.

$ docker build -t friendlyhello "/home/sxw455/App1"
unable to prepare context: path "/home/sxw455/App1" not found

But in Windows, the actual path is:

C:\Users\sxw455\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\home\sxw455\App1

And so I had to do this (even though I ran it from bash):

$ docker build -t friendlyhello 
"C:\Users\sxw455\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\home\sxw455\App1"

Sending build context to Docker daemon   5.12kB
Step 1/7 : FROM python:2.7-slim
 ---> 0dc3d8d47241
Step 2/7 : WORKDIR /app
 ---> Using cache
 ---> f739aa02ce04
Step 3/7 : COPY . /app
 ---> Using cache
 ---> 88686c524ae9
Step 4/7 : RUN pip install --trusted-host pypi.python.org -r requirements.txt
 ---> Using cache
 ---> b95f02b14f78
Step 5/7 : EXPOSE 80
 ---> Using cache
 ---> 0924dbc3f695
Step 6/7 : ENV NAME World
 ---> Using cache
 ---> 85c145785b87
Step 7/7 : CMD ["python", "app.py"]
 ---> Using cache
 ---> c2e43b7f0d4a
Successfully built c2e43b7f0d4a
Successfully tagged friendlyhello:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

I had similar problems with environment variables during the initial installation, and followed some advice that said to install the Windows DockerCE and hack the environment variables rather than installing the Ubuntu DockerCE, because (I hope I remembered this correctly) that WSL does not fully implement systemctl. Once the Windows Docker CE installation is done and environment variables are set, docker then works fine under WSL/Ubuntu.

Solution 12 - Docker

This command worked for me:

docker build -t docker-whale -f Dockerfile.txt .

Solution 13 - Docker

In windows 10, period is first parameter

docker build . -t docker-whale

Solution 14 - Docker

Two ways to build a dockerfile:

You can decide not to specify the file name of which to build from and just build it specifying a path (doing it this way the file name must be Dockerfile with no extension appended, eg: docker build -t docker-whale:tag path/to/Dockerfile

or

You can specify a file with -f and it doesn't matter what extension (within reason .txt, .dockerfile, .Dockerfile etc..) you decide to use, eg docker build -t docker-whale:tag /path/to/file -f docker-whale.dockerfile.

Solution 15 - Docker

I had originally created my Dockerfile in PowerShell and though I didn't see an extension on the file it showed as a PS File Type...once I created the file from Notepad++ being sure to select the "All types (.)" File Type with no extension on the File Name (Dockerfile). That allowed my image build command to complete successfully....Just make sure your Dockerfile has a Type of "File"...

Solution 16 - Docker

The problem is that the file name should be Dockerfile and not DockerFile or dockerfile it should be D capital followed by ockerfile in lower-case pls note

Solution 17 - Docker

Be sure your DOCKERfile is in the ROOT of the application directory, I had mine in src which resulted in this error because Docker was not finding the path to DOCKERfile

Solution 18 - Docker

The error means that docker build is either using a PATH | URL that are incorrectly input or that the Dockerfile cannot be found in the current directory. Also, make sure that when running the command from an integrated terminal (e.g. bash inside your IDE or text editor) you have the admin permissions to do so. Best if you can check the PATH from your terminal with pwd (in bash shell or dir if using a simple cli on windows) and copy the exact path where you want the image to be build.

docker build C:\windows\your_amazing_directory

docker build --help will also show you available options to use in case of malformed or illegal commands.

Solution 19 - Docker

To build Dockerfile save automated content in Dockerfile. not Dockerfile because while opening a file command:

$ notepad Dockerfile 

(A text file is written so file cannot build)

To build file run:

$ notepad Dockerfile

and Now run:

$ docker build -t docker-whale .

Make sure you are in current directory of Dockerfile.

Solution 20 - Docker

Most importantly make sure your file name is Dockerfile if you use another name it won't work(at least it did not for me.)

Also if you are in the same dir where the Dockerfile is use a . i.e. docker build -t Myubuntu1:v1 . or use the absolute path i.e docker build -t Myubuntu1:v1 /Users/<username>/Desktop/Docker

Solution 21 - Docker

I my case (run from Windows 10)

  1. Rename the file myDockerFile.Dockerfile to Dockerfile (without file extension).
    Then run from outside the folder this command:

    docker build .\Docker-LocalNifi\

This is working for me and for my colleagues at work, hope that will also work for you

Solution 22 - Docker

Make sure file name "Dockerfile" is not saved with any extension. Just create a file without any extension.

And make sure Dockerfile is in same directory from where you are trying to building docker image.

Solution 23 - Docker

In case if we have multiple docker files in our environment just Dockerfile wont suffice our requirement.

docker build -t ihub -f Dockerfile.ihub .

So use the file (-f argument) command to specify your docker file(Dockerfile.ihub)

Solution 24 - Docker

I got this on Windows when the path I was working in was under a Junction directory. So my fix was to not work under that path.

Solution 25 - Docker

On Mac it works for below command. (hope your .Dockerfile is in your root directory).

docker build -t docker-whale -f .Dockerfile .

Solution 26 - Docker

The issue is related to the DockerFile creation procedure.

In order to work, open cmd, cd to the directory of interest and type:

abc>DockerFile

This will create a file called DockerFile inside your folder.

Now type:

notepad DockerFile 

This will open the DockerFile file in notepad and you will have to copy/paste the standard code provided.

Save the file and now, finally, build your image with Docker typing:

docker build -t docker-whale . 

This is working for me and I hope it helps others

Solution 27 - Docker

I erroneously created Dockerfile.txt in my working directory leading to the above-mentioned error while build

The fix was to remove the .txt extension from the file.

The file name should be Dockerfile only without any extension.

Solution 28 - Docker

Execute docker build -t getting-started . in your project directory and make sure Dockerfile is present and having no .txt extension. If you are on Windows, check the 'file name extension' in the under the view tab in the File Explorer to show whether .txt is there or not and remove it if the former is true. Good Luck.

Solution 29 - Docker

I also faced the same issues and it was resolved when i created file named with DockerFile and mentioned all the command which wanted to get executed while creation of any image.

Solution 30 - Docker

If you have mounted a second drive to an NTFS folder as a 'mounted volume' then you can get this issue.

Move you files to a drive location outside of the mounted volume.

Solution 31 - Docker

please check whether docker is running on your windows or not, I try to find the solution and then accidently checked and find the issue

Solution 32 - Docker

Make sure you run the command

docker build . -t docker-whale 

from the directory that has the dockerfile

Solution 33 - Docker

In Linux, folders are case sensitive. I was getting this error because folder name TestAPI and was putting TestApi.

Solution 34 - Docker

I tried this and it worked:

$ docker build -t test_dotnet_image 
"C:\Users\ssundarababu\Documents\Docker\Learn\SimpleDockerfile"

Please see quotes+un-quotes around the foldername.

Note: In Folder "C:\Users\ssundarababu\Documents\Docker\Learn\SimpleDockerfile" I have my Dockerfile.

Solution 35 - Docker

To build an image from command-line in windows/linux.

  1. Create a docker file in your current directory. eg: FROM ubuntu RUN apt-get update RUN apt-get -y install apache2 ADD . /var/www/html ENTRYPOINT apachectl -D FOREGROUND ENV name Devops_Docker
  2. Don't save it with .txt extension.
  3. Under command-line run the command docker build . -t apache2image

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionvillanuxView Question on Stackoverflow
Solution 1 - Dockerkalyani chaudhariView Answer on Stackoverflow
Solution 2 - DockerLutz PrecheltView Answer on Stackoverflow
Solution 3 - DockerDivyanshu sachdevaView Answer on Stackoverflow
Solution 4 - DockerSharpCoderView Answer on Stackoverflow
Solution 5 - DockerVijayakumar PattanashettiView Answer on Stackoverflow
Solution 6 - DockerAlan FitzgeraldView Answer on Stackoverflow
Solution 7 - DockerSatyamView Answer on Stackoverflow
Solution 8 - DockerarunprakashpjView Answer on Stackoverflow
Solution 9 - DockerAurélienView Answer on Stackoverflow
Solution 10 - DockerHasanView Answer on Stackoverflow
Solution 11 - DockerComissarView Answer on Stackoverflow
Solution 12 - DockerAMAN BHARDWAJView Answer on Stackoverflow
Solution 13 - DockerPDAView Answer on Stackoverflow
Solution 14 - DockerPontiusTheBarbarianView Answer on Stackoverflow
Solution 15 - DockerHelper7123View Answer on Stackoverflow
Solution 16 - DockervincentView Answer on Stackoverflow
Solution 17 - DockerFrank OdoomView Answer on Stackoverflow
Solution 18 - Dockerrags2riches-progView Answer on Stackoverflow
Solution 19 - DockerniteshkumarmodiView Answer on Stackoverflow
Solution 20 - Dockerady6831983View Answer on Stackoverflow
Solution 21 - DockerYohanView Answer on Stackoverflow
Solution 22 - DockerNakeshView Answer on Stackoverflow
Solution 23 - Dockerchethan bhounsley gView Answer on Stackoverflow
Solution 24 - DockerChris F CarrollView Answer on Stackoverflow
Solution 25 - Dockercaldera.sacView Answer on Stackoverflow
Solution 26 - DockerEmployeeView Answer on Stackoverflow
Solution 27 - DockeriCantCView Answer on Stackoverflow
Solution 28 - DockerAbdellah RamadanView Answer on Stackoverflow
Solution 29 - DockerYoshita MahajanView Answer on Stackoverflow
Solution 30 - DockerGreg DomjanView Answer on Stackoverflow
Solution 31 - DockerArunView Answer on Stackoverflow
Solution 32 - DockerAjeigbe OladayoView Answer on Stackoverflow
Solution 33 - DockerGauravsaView Answer on Stackoverflow
Solution 34 - DockerSudharsan SView Answer on Stackoverflow
Solution 35 - DockerUdit GandhiView Answer on Stackoverflow