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