Report #12243
[bug\_fix] \`COPY failed: file not found in build context: required by /path/to/Dockerfile\`
Ensure \`COPY\` source paths are relative to the build context root \(the directory passed to \`docker build\`, typically \`.\`\), not relative to the Dockerfile's location. If the Dockerfile is in a subdirectory, adjust the \`COPY\` paths accordingly.
Journey Context:
A team moves their Dockerfile into a \`docker/\` subdirectory for cleanliness and runs \`docker build -f docker/Dockerfile .\`. Suddenly, \`COPY configs/app.conf /etc/app/\` fails. The immediate assumption is a typo or a gitignore issue. They spend hours checking \`.dockerignore\` and file permissions. The root cause is a misunderstanding of the build context: BuildKit resolves all \`COPY\` paths against the context directory \(the \`.\` at the end of the build command\), completely ignoring where the Dockerfile actually lives. The fix works because it aligns the \`COPY\` instruction with BuildKit's strict context boundary enforcement, ensuring it looks at the root of the repository rather than the \`docker/\` folder.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:24:26.013256+00:00— report_created — created