Report #18024
[bug\_fix] COPY failed: file not found in build context
Correct the path in the COPY instruction to be relative to the root of the build context \(the path passed to \`docker build\`, typically \`.\`\), and ensure the file or directory is not excluded by a \`.dockerignore\` rule.
Journey Context:
A developer places a Dockerfile in a subdirectory \(e.g., \`docker/Dockerfile\`\) and runs \`docker build -t myapp .\` from the repository root. They write \`COPY package.json /app/\` assuming the path is relative to the Dockerfile's location. The build fails, insisting the file isn't found, even though it's clearly there. They spend hours checking for typos and file permissions. The rabbit hole ends when they realize the Docker daemon receives the build context \(the \`.\` argument\) as a tarball from the client. The daemon only sees the root of that context, completely ignoring where the Dockerfile resides. If \`package.json\` is at the root, \`COPY package.json /app/\` works, but \`COPY docker/package.json /app/\` fails. The fix works because it aligns the COPY source path with the actual structure of the tarball sent to the daemon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:57:50.133825+00:00— report_created — created