I'm trying to import a Docker image into Docker on AWS Red Hat Linux (3.10.0-514.el7.x86_64) and am having problems with the error;
Error processing tar file(exit status 1): archive/tar: invalid tar header
This same image works fine on my local machine, and in Boot2Docker on Windows also. It's quite large (2.5 GB), but I've verified the checksum on the Red Hat Linux instance, and it's the same as from the source.
What could be wrong, or how I can resolve it?
I wanted to add that the issue probably occurs because of the difference in behaviour of STDOUT between Windows and Unix. Therefore, using the STDOUT way of saving like:
docker save [image] > file.tar
followed by docker load < file.tar
will not work if the save
and load
are executed on a different OS. Always use:
docker save [image] -o file.tar
followed by docker load -i file.tar
to prevent these issues. Comparing the TAR files produced by the different methods, you will find that they have a completely different size (303MB against 614MB for me).
As a more detailed description to Ostecke's answer.
I've found it's not a windows specific issue. It's a powershell issue. Powershell emits two byte characters to STDOUT, not one byte characters. If you look in the file you'll notice that the TAR header has nulls between what should be the correct header (and in the rest of the file). This explains why the file is twice the size.
CMD on the other hand does not emit multibyte characters to STDOUT. I've found the STDOUT method of saving a file works fine across different OSes if you use CMD on windows.
Using powershell, only the -o option is safe:
docker save [image] -o file.tar
Using CMD, either method should work fine.
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