Report #104246
[bug\_fix] COPY failed: file not found in build context or excluded by .dockerignore
Ensure the file or directory exists relative to the build context \(usually the Dockerfile directory or the context passed to docker build\). Verify .dockerignore does not exclude it. Use absolute paths in COPY only if the source is within the context.
Journey Context:
A developer was building a Docker image for a Node.js app. The Dockerfile had \`COPY package.json /app/\`. The build failed with 'file not found'. After checking the directory, package.json was present. The rabbit-hole deepened: the developer had a complex .dockerignore that excluded node\_modules and .git, but also accidentally excluded \*.json via a pattern like \`\*.json\` because they thought it would only match top-level. The fix: review .dockerignore line by line, and use \`COPY ./package.json /app/\` to be explicit. The real root cause was that COPY resolves paths relative to the build context, and .dockerignore patterns are applied to the entire context tree.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-19T20:06:51.044382+00:00— report_created — created