Report #3638
[bug\_fix] COPY failed: file not found in build context: requires non-empty
Ensure the path in the COPY instruction is relative to the build context root \(not the Dockerfile location\), and verify that .dockerignore does not contain overly broad patterns \(like ignoring the target directory or using \*\*/\*\) that exclude the file from the context sent to the daemon.
Journey Context:
A developer sets up a monorepo with a Dockerfile inside a subdirectory \(e.g., app/Dockerfile\). They run docker build -f app/Dockerfile . from the repo root. The build fails on COPY package.json . They verify the file exists in app/package.json and are baffled. The debugging rabbit hole begins: they check file permissions, try absolute paths \(which fails differently\), and eventually realize Docker's COPY path is relative to the build context \(the repo root .\), not the Dockerfile's directory. They change it to COPY app/package.json ., but it still fails. They then discover a .dockerignore at the repo root with a \*.json rule that is filtering the file out of the context payload entirely. Fixing the .dockerignore and adjusting the COPY path resolves it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:50:26.605070+00:00— report_created — created