[{"data":1,"prerenderedAt":120},["ShallowReactive",2],{"/2025/12/10-docker-build-copy-directory-not-found":3},{"id":4,"title":5,"body":6,"date":111,"description":55,"extension":112,"meta":113,"navigation":114,"path":115,"robots":116,"seo":117,"stem":118,"__hash__":119},"posts/2025/12/10 docker-build-copy-directory-not-found.md","10 Docker Build Copy Directory Not Found",{"type":7,"value":8,"toc":108},"minimark",[9,18,21,25,27,42,56,58,61,69,71,74,82,84,95,103,105],[10,11,13],"post-title",{":date":12},"date",[14,15,17],"h1",{"id":16},"docker-build-copy-directory-not-found","Docker Build Copy Directory Not Found",[19,20],"br",{},[22,23,24],"p",{},"So, I tried to provide parameter to Dockerfile since my CI/CD pipeline runs in Azure DevOps and the artifact staging directory is provided as variable and I don't want to hard code the value inside Dockerfile.",[19,26],{},[22,28,29,30,41],{},"Enter Build variables ",[31,32,35],"span",{"className":33},[34],"text-blue-600",[36,37,38],"a",{"href":38,"rel":39},"https://docs.docker.com/build/building/variables/",[40],"nofollow",". It seems simple. All I need in my dockerfile is:",[43,44,45],"code-block",{},[46,47,52],"pre",{"className":48,"code":50,"language":51},[49],"language-text","FROM ...\nARG SRC=\"./app\"\nCOPY ${SRC} .\n","text",[53,54,50],"code",{"__ignoreMap":55},"",[19,57],{},[22,59,60],{},"Then I can pass the value:",[43,62,63],{},[46,64,67],{"className":65,"code":66,"language":51},[49],"docker build --build-arg SRC=$(Build.ArtifactStagingDirectory) .\n",[53,68,66],{"__ignoreMap":55},[19,70],{},[22,72,73],{},"Well, it throws an error:",[43,75,76],{},[46,77,80],{"className":78,"code":79,"language":51},[49],"ERROR: failed to build: failed to solve: failed to compute cache key: failed to calculate checksum of ref 4ce6fa60-2f23-4ac2-b56a-0440c85af90a::qzmaj2vppe2uy3akiebhn7od1: \"/home/vsts/work/1/a\": not found\n",[53,81,79],{"__ignoreMap":55},[19,83],{},[22,85,86,87,94],{},"The path is correct, but somehow Docker can't find the directory. Apparently, it has something to do with build context ",[31,88,90],{"className":89},[34],[36,91,92],{"href":92,"rel":93},"https://docs.docker.com/build/concepts/context/",[40]," because the following works:",[43,96,97],{},[46,98,101],{"className":99,"code":100,"language":51},[49],"cd $(Build.ArtifactStagingDirectory)\ndocker build --build-arg SRC=. .\n",[53,102,100],{"__ignoreMap":55},[19,104],{},[22,106,107],{},"Which means only the directory on which the Dockerfile is being executed from and its subdirectories are accessible inside Dockerfile.",{"title":55,"searchDepth":109,"depth":109,"links":110},2,[],"2025-12-10T00:00:00.000Z","md",{},true,"/2025/12/10-docker-build-copy-directory-not-found",null,{"title":5,"description":55},"2025/12/10 docker-build-copy-directory-not-found","8KiJnc9FApbBXC6yiQRl_OUSO80M5FiYSJ_-nhThgYY",1785167452243]