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

后端 未结 30 2251
野性不改
野性不改 2020-11-29 21:23

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 Docke

相关标签:
30条回答
  • 2020-11-29 21:56

    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 .
    
    0 讨论(0)
  • 2020-11-29 21:56

    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.

    0 讨论(0)
  • 2020-11-29 21:56

    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

    0 讨论(0)
  • 2020-11-29 21:57

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

    0 讨论(0)
  • 2020-11-29 21:57

    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

    0 讨论(0)
  • 2020-11-29 21:57

    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.

    0 讨论(0)
提交回复
热议问题