Report #38958
[bug\_fix] COPY failed: file not found in build context: stat : file does not exist
Move the file into the build context directory, adjust the Dockerfile COPY path relative to the build context root, or remove the file from .dockerignore.
Journey Context:
A developer working in a monorepo runs docker build -t myapp . from the repository root, but their Dockerfile is inside a subdirectory \(e.g., ./services/api/Dockerfile\). The Dockerfile contains COPY package.json . and the build fails, claiming the file is not found. The developer verifies the file exists on their disk and gets stuck checking file permissions and symlinks. The breakthrough comes when they realize Docker resolves COPY paths strictly relative to the build context \(the . argument passed to docker build\), not the Dockerfile's location. Since package.json is in ./services/api/, the COPY instruction needs to be COPY services/api/package.json . relative to the context root.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:52:03.558914+00:00— report_created — created