CopyIgnoredFile
目录
注意
此检查是实验性的,默认情况下未启用。要启用它,请参见 实验性检查.
输出
Attempting to Copy file "./tmp/Dockerfile" that is excluded by .dockerignore描述
当你在Dockerfile中使用Add或Copy指令时,应确保要复制到镜像中的文件不匹配.dockerignore中存在的模式。
与.dockerignore文件中的模式匹配的文件在构建镜像时不会出现在上下文中。尝试复制或添加上下文中缺失的文件将导致构建错误。
示例
使用给定的 .dockerignore 文件:
*/tmp/*❌ 错误:尝试复制被 .dockerignore 排除的文件 "./tmp/Dockerfile"
FROM scratch
COPY ./tmp/helloworld.txt /helloworld.txt✅ 良好:复制未被 .dockerignore 排除的文件
FROM scratch
COPY ./forever/helloworld.txt /helloworld.txt