Report #77158
[bug\_fix] COPY failed: file not found in build context:
Ensure the COPY source path is relative to the build context root \(usually the repository root\), not relative to the Dockerfile location. Additionally, verify that the file or directory is not being excluded by a .dockerignore file.
Journey Context:
A developer moves their Dockerfile into a subdirectory \(e.g., docker/Dockerfile\) to tidy the repository root. They update their CI pipeline to run docker build -f docker/Dockerfile . and suddenly the build fails with a file not found error. They spend hours verifying file permissions, checking git tracking, and confirming the file exists on the CI runner. The rabbit hole deepens when they try absolute paths inside the Dockerfile, which also fails. The root cause is a fundamental Docker mechanic: all COPY paths are resolved relative to the build context \(the . at the end of the build command\), not the Dockerfile's location. Because they didn't change the COPY paths to reflect the context root, Docker cannot find the files. Alternatively, they might have inadvertently added a broad pattern like \*.json to their .dockerignore, silently excluding the required files from the context entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:06:17.330272+00:00— report_created — created