Report #44303
[bug\_fix] COPY dumps files into the wrong directory structure or overwrites the destination folder contents unexpectedly
Remove the trailing slash from the source directory in the COPY instruction if you intend to copy the directory itself along with its contents. \`COPY mydir /app/\` copies the \*contents\* of mydir into /app, whereas \`COPY mydir /app/mydir\` copies the directory itself.
Journey Context:
A developer writes \`COPY config/ /etc/app/\` expecting the final structure to be \`/etc/app/config/settings.ini\`. Instead, they find \`settings.ini\` directly inside \`/etc/app/\`, overwriting other files. They try adjusting the destination path, but are confused by the behavior. They test various combinations and discover Docker's specific rule for the COPY instruction: if the source is a directory, the directory itself is not copied, only its contents. The trailing slash on the source is a visual hint but doesn't change this behavior. To copy the folder itself, they must specify the destination folder explicitly as \`COPY config /etc/app/config\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:50:03.965224+00:00— report_created — created