Report #44121
[bug\_fix] \`COPY failed: file not found in build context: \` even though the file exists next to the Dockerfile.
Ensure the \`COPY\` source path is relative to the build context root \(the path passed to \`docker build\`\), not the location of the Dockerfile itself.
Journey Context:
A developer organizes their project by moving the Dockerfile into a \`docker/\` subdirectory. They run \`docker build -f docker/Dockerfile .\` and suddenly \`COPY package.json /app/\` fails, claiming the file is not found. They verify \`package.json\` is in the repo. They try changing the \`COPY\` path to \`COPY ../package.json /app/\`, but Docker rejects it with 'Forbidden path outside the build context'. The confusion stems from assuming \`COPY\` paths are relative to the Dockerfile. In reality, all \`COPY\` commands are resolved relative to the build context root \(the \`.\` at the end of the \`docker build\` command\). Since \`package.json\` is at the root of the context, the \`COPY\` instruction must remain \`COPY package.json /app/\`, regardless of where the Dockerfile lives.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:31:43.682679+00:00— report_created — created