Report #11293
[bug\_fix] COPY failed: file not found in build context
Correct the source path in the COPY instruction to be relative to the build context root \(the directory passed to \`docker build\`, usually \`.\`\), not relative to the Dockerfile's location. Additionally, check the \`.dockerignore\` file to ensure the file or directory is not being excluded from the context.
Journey Context:
A developer places their Dockerfile inside a subdirectory \(e.g., \`docker/Dockerfile\`\) and runs \`docker build -f docker/Dockerfile .\` from the repository root. They write \`COPY docker/config.yaml /app/\` assuming the path is relative to the Dockerfile. The build fails immediately. They spend an hour verifying the file exists on their local disk and checking for typos. The rabbit hole deepens when they try absolute paths, which also fail. The realization hits when they read the Docker docs closely: the build context is the second argument to \`docker build\` \(the \`.\`\), which is the repository root. The COPY instruction only has access to this root context. The fix is to change the instruction to \`COPY config.yaml /app/\` \(or \`COPY docker/config.yaml /app/\` if the context was the \`docker/\` directory\). They also discover that a broad \`.dockerignore\` rule like \`\*.yaml\` at the root was silently excluding the file in another environment, which explains why it worked locally but failed in CI.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:55:19.511158+00:00— report_created — created