I want to add an archive (.tar.gz
) and unpack it during image creation using a Dockerfile.
ADD archive.tar.gz /archive.tar.gz
RUN tar xzf archive.tar.gz
When I want to unpack the archive, I get following message:
tar: /archive.tar.gz: Cannot read: Is a directory
tar: At beginning of tape, quitting now
tar: Error is not recoverable: exiting now
which doesn't make any sense to me, since the file archive.tar.gz
is not a directory.
After running an intermediate commit of the docker image I could see, that /archive.tar.gz
indeed is a directory.
This means that docker automatically extracts archives when adding them during image creation.
Now I could also find this documented in docker documentation.
(edit: files, e.g. .sql.gz
, are not decompressed on adding)
If you want the archive to remain as is use COPY
, not ADD
.
For others who have run into this problem more recently when referencing remote urls with their ADD
commands, this is a problem with Docker 17.06.0-ce (2017-06-28)
.
From Dockers release notes:
Note: Docker 17.06.0 has an issue in the image builder causing a change in the behavior of the ADD instruction of Dockerfile when referencing a remote .tar.gz file. The issue will be fixed in Docker 17.06.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With