Search code examples
dockerubuntu-20.04

Docker hangs when pulling images or runing containers


I'm facing a strange behavior using docker on Ubuntu 20.04 (I'm using this in a corporate environment). Since 2 days, I'm completely unable to run containers or even pull images from Docker Hub.

When trying to pull any image from Docker Hub (even the hello-world), the image is downloaded locally and then docker freezes as you can see on the following picture docker run hello-world

I first tried to restart the docker daemon and even the machine (as this is my development computer) => NOK.

Then I tried to completely reinstall the docker package and all its dependencies using the following commands:

sudo apt purge docker docker.io
sudo apt autoremove --purge docker docker.io
sudo rm -rf /var/lib/docker
sudo rm -rf /etc/docker
rm -rf ~/.docker
sudo apt install docker.io

Result => NOK.

The next step was to reinstall my Ubuntu 20.04 machine => NOK.

I also tried to limit simultaneous connections of docker daemon to only one as I read on some forums some people have experienced similar problems and they solved this by limiting simultaneous connections => NOK

I tried to move the location of the docker root folder by adding the following content to /etc/docker/daemon.json => NOK.

{
   "data-root": "/var/lib/docker"
}

I added --debug flag to dockerd command line to get more info on what's happening and here is what I get when I try to run hello-world container:

sept. 09 16:09:38 dockerd[1842]: time="2021-09-09T16:09:38.582649566+02:00" level=debug msg="pulling blob \"sha256:b8dfde127a2919ff59ad3fd4a0776de178a555a76fff77a506e128aea3ed41e3\""
sept. 09 16:09:39 dockerd[1842]: time="2021-09-09T16:09:39.290277164+02:00" level=debug msg="Downloaded b8dfde127a29 to tempfile /var/lib/docker/tmp/GetImageBlob129841538"
sept. 09 16:09:39 dockerd[1842]: time="2021-09-09T16:09:39.290586225+02:00" level=debug msg="Using /usr/bin/unpigz to decompress"
sept. 09 16:09:39 dockerd[1842]: time="2021-09-09T16:09:39.296254339+02:00" level=debug msg="Applying tar in /var/lib/docker/overlay2/91e5944b0c0d34d010b4f28036e29d47213266af5677660edbb00470160fb186/diff" storage-driver=overlay2

The blob is present into /var/lib/docker/tmp and the folder /var/lib/docker/overlay2/91e5944b0c0d34d010b4f28036e29d47213266af5677660edbb00470160fb186/diff is created but is empty.


Solution

  • Finally, the problem origin was a bad configuration of the docker so that it can work into our corporate network. After flushing the docker once again => reinstall => reconfigure completely => OK

    Edit: The process followed to flush and reinstall the docker is described above. The issue was coming from the configuration of the docker so that it can use the corporate proxy to access the public dockerhub repo. This is described here : https://docs.docker.com/network/proxy/