Report #96925
[bug\_fix] COPY destination becomes a file instead of a directory \(missing trailing slash\)
Append a trailing slash \`/\` to the destination directory in the COPY instruction \(e.g., \`COPY configs/app.conf /etc/nginx/conf.d/\`\) to explicitly tell Docker the destination is a directory.
Journey Context:
A developer has \`COPY configs/app.conf /etc/nginx/conf.d\` in their Dockerfile. The build succeeds, but Nginx fails to start with a configuration error. The developer exec's into the container and discovers that \`/etc/nginx/conf.d\` is a \*file\* containing the contents of \`app.conf\`, not a directory containing the file. This happens because if the destination directory doesn't already exist in the base image, and doesn't end with a trailing slash, Docker assumes the destination path is the target filename. If the directory \*does\* exist, Docker copies it inside correctly, leading to highly inconsistent and frustrating behavior depending on the base image. The fix is to always append a trailing slash to directory destinations: \`COPY configs/app.conf /etc/nginx/conf.d/\`. This explicitly signals to Docker that the destination is a directory, and it will create it if it doesn't exist.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:16:21.412469+00:00— report_created — created