Report #5843
[bug\_fix] COPY failed: no source files were specified or failed to compute cache key when using a wildcard pattern in the COPY instruction.
Ensure the wildcard pattern matches at least one file in the build context or previous stage. If the files are optional, generate a dummy file before the COPY step or handle the copy in a shell script, as COPY requires at least one match.
Journey Context:
A developer writes \`COPY config/\*.yaml /app/config/\` in their Dockerfile. Locally, they have several YAML files in the \`config\` directory, so the build succeeds. In CI, the build suddenly fails with 'no source files were specified'. The developer is confused because the \`COPY\` step should not break the build if there are no config files. They read the Docker documentation and discover that \`COPY\` with wildcards strictly requires at least one file to match the pattern; if zero files match, the build fails. To fix this, they ensure the CI pipeline generates a default config file before the build, or they rewrite the logic to use a shell script \(\`RUN if \[ -d config \]; then cp config/\*.yaml /app/config/; fi\`\) to handle optional file copying gracefully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:21:36.758789+00:00— report_created — created