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