Ashwin
Ashwin

Reputation: 51

Docker pull Error - failed to register layer: Error processing tar file(exit status 1): archive/tar: invalid tar header

I am getting an error when trying to pull docker images on my Ubuntu machine. Below is an example of when I get the error. -

$ sudo docker pull postgres:14

14: Pulling from library/postgres
3f9582a2cbe7: Extracting  31.41MB/31.41MB
0d9d08fc1a1a: Download complete 
ecae4ccb4d1b: Download complete 
e75693e0d7a5: Download complete 
1b6d5aead1a8: Download complete 
f2aa67d9a6b2: Download complete 
7a3ec0371e36: Download complete 
704d9d1b662d: Download complete 
54524e056363: Download complete 
25bf4c84ca22: Download complete 
40b6f9f7a0cb: Download complete 
78ab4b71d139: Download complete 
abd467968b89: Download complete 
failed to register layer: Error processing tar file(exit status 1): archive/tar: invalid tar header

Additional information -

$ docker --version
Docker version 23.0.1, build a5ee5b1

Things I tried to fix this issue and none of them helped-

  1. Remove all docker images and restart docker service
  2. Completely uninstall and reinstall docker
  3. Tried pulling a different image. I was able to pull ubuntu:latest successfully. But I get the error when I tried to pull pcl image dlopezmadrid/pcl-docker:latest

Any advice on how to fix this would be very helpful.

Upvotes: 3

Views: 6395

Answers (4)

Alexey Khachatryan
Alexey Khachatryan

Reputation: 187

I got that error after upgrading docker on my Ubuntu machine and string the project. The simple rebuild fixed the issue:

@docker compose up -d --build && docker-compose start

Upvotes: 0

ralph
ralph

Reputation: 93

I also had this problem with docker pull and larger images. In my case, the cause for this error was broken/damaged RAM. After detecting with memtest and removing the faulty sticks, the pull worked again.

Upvotes: 0

Philip C.
Philip C.

Reputation: 21

I was also having this issue on Docker version 20.10.21

Upgraded to Docker version 24.0.5 and the issue no longer occurred.

Upvotes: 1

Ashwin
Ashwin

Reputation: 51

So I was able to find a workaround for this issue after a lot of online digging. The solution is to disable parallel decompression for docker images on the host. Here's how you can do it:

  1. Open the Docker systemd unit file /lib/systemd/system/docker.service using a text editor with root permissions:

sudo nano /lib/systemd/system/docker.service

  1. Add the following line under the [Service] section:

Environment=MOBY_DISABLE_PIGZ=1

  1. Save the file and reload the systemd configuration:

sudo systemctl daemon-reload

  1. Restart the Docker daemon for the changes to take effect:

sudo systemctl restart docker

After restarting the Docker daemon, parallel decompression should be disabled for Docker images on the host.

Note that this method modifies the Docker service directly, so any changes made to the systemd unit file will persist across system reboots.

Also, the downside to this workaround is that it'll take longer for you to pull images.

Upvotes: 1

Related Questions