I'm installing sqlite on Alpine Linux. I download sqlite-autoconf-3130000.tar.gz but tar could not open it. I tried this answer but it's not working. tar gives this message:

tar: invalid magic
tar: short read

I wrote these commands.

wget https://www.sqlite.org/2015/sqlite-autoconf-3090100.tar.gz
tar -zxvf sqlite-autoconf-3090100.tar.gz
  • Could you please update your answer with the command (and its arguments) that you tried to run. – DarkHeart Aug 9 '16 at 6:56
  • 1
    Did the download complete successfully? If it did, ls -l sqlite-autoconf-3090100.tar.gz should tell you that the file is 2284128 bytes in size. – Stephen Kitt Aug 9 '16 at 7:50
  • Also, is it currently a gzip formatted file? Some browsers do on the fly decompression, meaning that it might still named sqlite-autoconf-3090100.tar.gz but that the contents might actually be sqlite-autoconf-3090100.tar. No idea if wget does equally smart things, but it is easily tested by leaving of the z flag from tar. – Hennes Jan 25 '17 at 9:06

Try to install the tar package (apk add tar). Busybox tar (default) doesn't support all features.

  • 3
    I ran into the same issue when running a tar command in a Dockerfile and installing tar worked for me. It's kind of confusing because if you run the command in the shell in the container, it works. But not if it's a RUN command in the Dockerfile without having installed tar first. :| – 3cheesewheel Oct 10 '16 at 12:06

This doesn't necessarily mean the Alpine version of tar is incompatible, as Francesco pointed out you should really check your file checksums.

I ran into this while doing a curl https://github.com/someproject/releases/project-1.1.0.gz | tar -xvzf in my Dockerfile.

It turns out what I had forgotten was that curl will only follow redirects if you allow it with -L, and so it was never getting to the actual file, it was literally downloading the html telling it there was a redirect. Adding the -L allowed me to save the file without bloating my container with a new tar (beyond the "bloat" added by curl).


tar:invalid magic means that the file is corrupted.

Please check the md5sum if matches...this is what i got:

 md5sum  sqlite-autoconf-3090100.tar.gz 
 74931054399a2d7acf35637efe8d6f45  sqlite-autoconf-3090100.tar.gz

I got the same issue and solved it, however I'm not sure you are facing the same issue.

Code that Caused error:

wget www.example.com/file.tar.gz
tar -zxvf file.tar.gz

Code that resolved it:

wget https://www.example.com/file.tar.gz
tar -zxvf file.tar.gz

Notice that I had forgoten the "https://" wherein the file did get downloaded but the tar gave me the same error. If the file is not found make sure you use

docker build --no-cache ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.