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