首页 文章

Docker:无法准备上下文:无法评估Dockerfile路径中的符号链接:GetFileAttributesEx

提问于
浏览
73

我今天刚刚下载了适用于Windows 10 64bit的Docker Toolbox . 我正在阅读教程 . 尝试使用Dockerfile构建映像时,我收到以下错误 .

脚步:

  • 推出Docker Quickstart终端 .

  • testdocker创建后 .

  • 按照"Build your own image" web链接中的说明准备Dockerfile

  • 跑"docker build -t docker-whale ."

错误:$ docker build -t docker-whale . 无法准备上下文:无法评估Dockerfile路径中的符号链接:GetFileAttributesEx C:\ Users \ Villanueva \ Test \ testdocker \ Dockerfile:系统找不到指定的文件 .

BTW: 我尝试了几个提到的选项@ 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

16 回答

  • 0

    这只是因为Notepad在Dockerfile的末尾添加了“.txt”

  • -1

    执行以下命令时:

    "docker build -t docker-whale ."
    

    检查当前工作目录中是否存在Dockerfile .

  • 5

    如果您正在使用Windows 8,那么您将使用Docker工具箱 . 从mydockerbuild目录运行以下命令,因为Dockerfile是一个文本文件

    docker build -t docker-whale -f ./Dockerfile.txt .
    
  • 1

    只需从Dockerfile中删除扩展名.txt并运行该命令

    docker build -t image-name
    

    它肯定会起作用 .

  • 22

    我已经命名了我的文件dockerfile而不是Dockerfile(大写),一旦我改变了它,它开始处理我的“Dockerfile” .

  • 3

    我有这个错误(在MacBook中)虽然我用正确的命令来创建图像,

    docker build -t testimg .
    

    后来我发现路径就是问题所在 . 只需导航到包含docker文件的正确路径即可 . 只需仔细检查您当前的工作目录 . 没什么可惊慌的!

  • 8

    在Windows 10中...句点是第一个参数

    docker build . -t docker-whale

  • 1

    我最初在PowerShell中创建了我的Dockerfile,虽然我没有看到它显示为PS文件类型的文件的扩展名...一旦我从记事本创建文件,一定要选择“所有类型( . )" 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 "文件” ...

  • 0

    问题是文件名应该是Dockerfile而不是DockerFile或dockerfile它应该是D大写,后跟ockerfile,小写请注意

  • 0

    在Dockerfile中构建Dockerfile保存自动化内容 . 不是Dockerfile,因为在打开文件命令时:

    $ notepad Dockerfile
    

    (写入文本文件,因此无法构建文件)

    要构建文件运行:

    $ notepad Dockerfile
    

    现在运行:

    $ docker build -t docker-whale .
    

    确保您位于Dockerfile的当前目录中 .

  • 95

    我通过VS2017 Docker支持工具创建了我的DockerFile并且出现了同样的错误 . 过了一会儿,我意识到我不在包含Dockerfile的正确目录中(〜\ source \ repos \ DockerWebApplication) . 点击项目内部的正确文件(〜/ source / repos / DockerWebApplication / DockerWebApplication)并成功创建了docker镜像 .

  • 1

    在WSL中,路径转换似乎存在问题 . Dockerfile在Ubuntu中的位置(我正在运行docker和Dockerfile所在的位置)是“/ home / sxw455 / App1”,但这两个命令都不起作用:

    $ 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
    

    但在Windows中,实际路径是:

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

    所以我必须这样做(即使我从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.
    

    我在初始安装期间遇到了与环境变量类似的问题,并遵循一些建议,说安装Windows DockerCE并破解环境变量而不是安装Ubuntu DockerCE,因为(我希望我能记住这一点)WSL没有完全实现systemctl . 完成Windows Docker CE安装并设置环境变量后,docker在WSL / Ubuntu下运行正常 .

  • 10

    当我在工作的路径在Junction目录下时,我在Windows上得到了这个 . 所以我的修复是不能在那条路上工作 .

  • 3

    On Mac 适用于以下命令 . (希望你的 .Dockerfile 在你的根目录中) .

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

    该问题与DockerFile创建过程有关 .

    为了工作,打开cmd,cd到感兴趣的目录并输入:

    abc>DockerFile
    

    这将在您的文件夹中创建一个名为DockerFile的文件 .

    现在输入:

    notepad DockerFile
    

    这将在记事本中打开DockerFile文件,您必须复制/粘贴提供的标准代码 .

    保存文件,现在,最后,使用Docker键入来构建您的图像:

    docker build -t docker-whale .
    

    这对我有用,我希望它能帮助别人

  • 2

    我试过这个并且它有效:

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

    请参阅foldername周围的引号 .

    注意:在文件夹 "C:\Users\ssundarababu\Documents\Docker\Learn\SimpleDockerfile" 我有我的Dockerfile .

相关问题