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

394,179

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

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

  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.
Share:
394,179

Related videos on Youtube

villanux
Author by

villanux

Updated on September 28, 2021

Comments

  • villanux
    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
      villanux almost 7 years
      Update: docker build -t XXX --file ./Dockefile . worked. Docker may want to update their documentation for Windows users.
    • eXa
      eXa over 6 years
      If docker build -t XXX --file ./Dockefile it might be because you got the filename wrong it's missing the R.
    • RichVel
      RichVel almost 6 years
      This is an amazingly bad error message, it just means "cannot open file" - same on Linux and macOS.
    • lmat - Reinstate Monica
      lmat - Reinstate Monica over 2 years
      Mind-blowingly bad error message.
  • IanGSY
    IanGSY about 6 years
    Thanks. My issue was I had created my Dockerfile in Notepad and it had automatically appended .txt to the filename.
  • Sumi Straessle
    Sumi Straessle almost 6 years
    You may also explicitly write the Dockerfile name with the fflag, as in docker 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
    sebagomez over 5 years
    not anymore (if ever) docker build -t docker-whale . is a valid command
  • K. Brafford
    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 years
    for 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
    Per Lundberg almost 5 years
    Notepad is an excessively evil program.
  • Mike Kellogg
    Mike Kellogg almost 5 years
    if you're following along on the docker documentation "getting started" tutorial you would use this: docker build -t friendlyhello -f ./Dockerfile.txt .
  • myloginid
    myloginid over 4 years
    Its 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
    Lawrence Lee almost 4 years
    This 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 years
    This 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
    Paul Gear about 3 years
    I think this would be a lot stronger (and more relevant) an answer without the 2nd half.
  • leon.io about 3 years
    Great answer, and thanks for the background information
  • Donald Shahini about 3 years
    Dockerfile is not a .txt file. If you have it as a .txt file it will give error again.
  • Purplejacket
    Purplejacket over 2 years
    It's also necessary to have the . (dot) at the end of the line, as the above shows.
  • Purplejacket
    Purplejacket over 2 years
    Documentation for docker build is here: docs.docker.com/engine/reference/commandline/build
  • Ayyappa
    Ayyappa over 2 years
    I 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
    Junaid about 2 years
    Filename did the trick for me. I had to change DockerFile to Dockerfile
  • Saites
    Saites almost 2 years
    Likewise, check for simple spelling errors. I landed here because Dockefile is certainly not the same as Dockerfile :facepalm: Since building with docker build -f <tab-completed filename> . worked, I looked closer and realized I had mistyped it.
  • Kraken
    Kraken almost 2 years
    When you need a reminder that you're calling from the wrong directory xD
  • Christopher Markieta
    Christopher Markieta almost 2 years
    Copied something weird after the trailing period, removing this helped.
  • Ukrainian-serge 8 months
    big help on the Dockerfile instead of DockerFile

Related