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