Report #79747
[bug\_fix] A tar.gz file added via \`ADD archive.tar.gz /app/\` is prematurely extracted into the \`/app/\` directory, breaking startup scripts that expect the file to exist at \`/app/archive.tar.gz\`.
Use \`COPY archive.tar.gz /app/\` instead of \`ADD\`. \`COPY\` is strictly a file-copy operation and does not have implicit extraction magic.
Journey Context:
A developer needs to copy a large tarball into a container to be extracted at runtime by an entrypoint script \(perhaps to save image size via a custom squash strategy or overlayfs\). They use \`ADD archive.tar.gz /app/\`. The build succeeds, but the container crashes at startup because the script looks for \`/app/archive.tar.gz\` and it isn't there. The developer inspects the built image layers and discovers the tarball was automatically extracted, dumping its contents directly into \`/app/\`. They spend time checking tar versions and flags, wondering why it extracted without being told to. The rabbit hole ends at the Docker documentation: \`ADD\` has a historical 'magic' feature where if the source file is a locally compressed tar archive, it automatically extracts it into the destination. The fix works because \`COPY\` was introduced specifically to provide a transparent, predictable file-copy operation without the implicit extraction behavior, ensuring the tarball remains intact.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:27:31.435488+00:00— report_created — created