【问题标题】:unable to prepare context: unable to evaluate symlinks in Dockerfile path for windows 10无法准备上下文:无法评估 Windows 10 的 Dockerfile 路径中的符号链接
【发布时间】:2021-06-06 23:06:42
【问题描述】:

我在C:\Users\user_name\ 目录下创建了Dockerfile.txt

文件内容为:

FROM centos

RUN yum install -y java

VOLUME /tmp
ADD /test-0.0.1-SNAPSHOT.jar myapp.jar
RUN sh -c 'touch /myapp.jar'
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/myapp.jar"]

我将 Dockerfile 和 uber jar 移到了 C:\Users\user_name\ 下,并在 PowerShell 中的 C:\Users\user_name\ 下执行了命令。

docker build -t spring-boot-docker .

我收到此错误:

无法准备上下文:无法评估 Dockerfile 中的符号链接 路径:GetFileAttributesEx C:\Users\user_name\Dockerfile:系统 找不到指定的文件。

知道如何解决这个问题吗?

谢谢

【问题讨论】:

  • Dockerfile 不是Dockerfile.txt
  • docker build -t spring-boot-docker -f Dockerfile.txt .

标签: windows powershell docker spring-boot


【解决方案1】:

docker 将默认为一个名为 Dockerfile 的文件,没有扩展名。由于您将 Dockerfile 命名为 Dockerfile.txt,因此您必须为其提供 -f 标志。

docker build -t spring-boot-docker -f Dockerfile.txt .

【讨论】:

  • 在新目录中移动 jar 和 Dockerfile.txt 并运行命令“docker build -t spring-boot-docker -f .\Dockerfile.txt”后。在新目录下的 PowerShell 中为我做了诀窍。谢谢
【解决方案2】:

我将文件命名为Dockerfile(在Windows下的Git CMD中),结果是

docker build .

unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx C:\*windows-path*\Dockerfile: The system cannot find the file specified.

所以我将它从 Dockerfile 更改为 Dockerfile.txt 并使用 -f 选项:

docker build -t test_image -f ".\Dockerfile.txt" .

它成功了:)

【讨论】:

    猜你喜欢
    • 2016-06-01
    • 1970-01-01
    • 2019-10-27
    • 2020-12-06
    • 2020-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多