gpt4 book ai didi

java - 是否不允许忽略 '.dockerignore' 中的 Dockerfile?

转载 作者:行者123 更新时间:2023-12-02 01:59:26 25 4
gpt4 key购买 nike

(注意:这似乎与 Jenkins 无关,但标记它以防万一)

我正在使用 Jenkins Docker 插件来构建我的 docker 镜像,但是我的构建失败并出现以下异常:Dockerfile 被 .dockerignore 文件中的模式“Dockerfile”排除

com.github.dockerjava.api.exception.DockerClientException: Dockerfile is excluded by pattern 'Dockerfile' in .dockerignore file
at com.github.dockerjava.core.dockerfile.Dockerfile$ScannedResult.<init>(Dockerfile.java:184)
at com.github.dockerjava.core.dockerfile.Dockerfile.parse(Dockerfile.java:111)
at ...

看起来它使用 docker-java图书馆

检查源代码后发现,如果此处忽略 Dockerfile,则会引发异常: Dockerfile.java:L185

那么忽略 Dockerfile 是不允许的吗?为什么?

最佳答案

支持忽略 Dockerfile,但并不总是如此。来自 current documentation :

You can even use the .dockerignore file to exclude the Dockerfile and .dockerignore files. These files are still sent to the daemon because it needs them to do its job. But the ADD and COPY instructions do not copy them to the image.

早在 1.5.0 中就添加了对此的支持(发布于2015-02-10):

Dockerfile and .dockerignore files can be themselves excluded as part of the .dockerignore file, thus preventing modifications to these files invalidating ADD or COPY instructions cache

关于java - 是否不允许忽略 '.dockerignore' 中的 Dockerfile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51860331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com