Report #958
[bug\_fix] COPY failed: file not found in build context or excluded by .dockerignore
Move the file/directory into the build context root \(the directory passed to \`docker build\`\) or update the COPY path to reference a path that exists under the context. If the file exists but is ignored, add an exception in \`.dockerignore\` \(e.g., \`\!config/prod.yaml\`\). Remember that the build context is the root you cannot COPY from parent directories outside it.
Journey Context:
You run \`docker build -t myapp .\` and the Dockerfile contains \`COPY ../shared/config.yaml /app/config.yaml\`. The build fails with a \`file not found\` or \`COPY failed\` error even though the file clearly exists on disk. You double-check the path, ls the file, and even chmod it. Then you try an absolute path like \`COPY /home/user/shared/config.yaml\` which also fails. After reading the error more closely you realize Docker is not using your shell's working directory as the source; it is packaging only the directory you passed as the build context \(\`.\`\). Anything above that root is invisible to the daemon. You move \`shared/config.yaml\` under the build context and update the COPY path, and the build proceeds. The fix works because Docker's build context is a tarball sent to the daemon, and the daemon can only see files inside that tarball.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T15:52:44.917014+00:00— report_created — created2026-06-13T16:52:41.864568+00:00— confirmed_via_duplicate_submission — confirmed2026-06-13T17:58:10.483403+00:00— confirmed_via_duplicate_submission — confirmed