8

I upgraded my Ubuntu from 18.04 to 20.04. I have been unable to run all my docker containers. Tried uninstalling docker and re-installing via links such as this. When using apt, the installation freezes on the configuration of docker. The installation is not able to start docker.

Eventually, it seems to boil down to a configuration problem.

 user@user-pc:~$ sudo dpkg --configure -a
 Setting up docker-ce (5:20.10.1~3-0~ubuntu-focal) ... 
 /bin/sh: 0: Illegal option -w
 dpkg: error processing package docker-ce (--configure):
 installed docker-ce package post-installation script subprocess returned error exit status-2
 dpkg: dependency problems prevent configuration of docker-ce-rootless-extras:
 docker-ce-rootless-extras depends on docker-ce; however:
 Package docker-ce is not configured yet.

 dpkg: error processing package docker-ce-rootless-extras (--configure):
 dependency problems - leaving unconfigured
 Processing triggers for man-db (2.9.1-1) ...
 Errors were encountered while processing:
 docker-ce
 docker-ce-rootless-extras

The docker status

sudo service docker status

Shows that docker is active but any docker command hangs forever. Also docker-compose commands timeout.

docker-compose logs -f 
...
...
docker.errors.DockerException: Error while fetching server API version: UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

I am stumped, been trying to resolve this, three days now.

5 Answers 5

20

Do you have a VPN running in the background while installing docker?

Apparently, tunneling your network [while installing docker leads to problems][1]. It just happened to me as well. Turned off openvpn via

sudo service openvpn stop

and docker installed beautifully.

5
  • It happen on 20.04 too. Really thanks, turned off openconnect and the error not happen again. Jan 13, 2021 at 18:39
  • Same happended to me. Disable VPN before installing worked for me! Thanks
    – jobima
    Feb 5, 2021 at 11:45
  • temporarily turning off tailscale fixed this issue, thanks!
    – asg0451
    Jan 15, 2023 at 3:09
  • I use fortclient, turned it off and it worked for me as well. thanks a lot Mar 27, 2023 at 20:31
  • finally saved me ! ubuntu 22.04 wsl2 Dec 1, 2023 at 9:37
6

I had a similar issue. After Ubuntu upgrade from 18.04.4 to 20.04.2 docker would not start, and errored when trying to install, remove, purge, repair it. (VPN is outside of my control).

$ sudo apt-get purge -y docker-ce
...
1 not fully installed or removed.
...
Removing docker-ce (5:20.10.4~3-0~ubuntu-bionic) ...
Job for docker.service canceled.
invoke-rc.d: initscript docker, action "stop" failed.
dpkg: error processing package docker-ce (--remove):
 installed docker-ce package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
dpkg: error while cleaning up:
 installed docker-ce package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 docker-ce
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

I had both docker.io from Debian/Ubuntu and docker-ce from docker.com installed. This post discusses the differences.

dpkg -l | grep -i docker

Looks for me it was choking on containerd which would not start. You can check messages in /var/log/syslog

Removing folders, uninstalling all docker packages and reinstalling docker.io worked.

NOTE: I did not care about previous images or containers, if you do then this might NOT work for you.

$ sudo rm -rf /var/lib/containerd/
$ sudo rm -rf /var/lib/docker/
$ sudo apt-get purge -y docker-ce docker-ce-cli docker.io containerd.io
$ sudo apt-get install docker.io
2
  • this works for me. Thanks
    – thsieh
    Feb 24, 2022 at 22:17
  • 1
    I had what sounds like the same issue with containerd not starting, and it was "out of the blue" in my case. This occurred on an Ubuntu 20.04 LTS installation inside WSL2 on Windows 10 21H2. Windows Updates have butchered my WSL installation before, and one was installed just prior to this problem occurring, so I remain suspicious! Your instructions worked great (but I had to kill some lingering Docker-related processes before I could delete the directories). Thanks! Dec 15, 2022 at 17:52
1

Updating { "storage-driver": "devicemapper" }

in daemon.json and restarting docker service solved this problem.

nano /etc/docker/daemon.json
#Add 
{ "storage-driver": "devicemapper" }
#Save and exit

restart docker service.

Referred this from issue link https://github.com/moby/moby/issues/22685

0

Additional note for wireguard users rather than openvpn:

Same happened to me while having wireguard installed. Even when the tunnel is not active, the issue is present.

As the solution from Timon suggests, you can do the same with Wireguard by running the following commands:

sudo systemctl stop [email protected]
sudo apt remove docker-ce
sudo apt install docker-ce
sudo systemctl start [email protected]

Note: wg0 can potentially be something else if you have used another name during setup. You can use the tab button after writing wg-quick@ to find your version.

0

In my case, I had installed Firewalld instead of ufw which is the “default” on Ubuntu.

The issue is that the docker0 interface in a previous installation was set to “trusted” zone, so apt was unable to create a new interface with that name and then failed to finish the installation process.

What I did was to use the firewall-cmd tool to remove the interface.

firewall-cmd --zone=trusted --remove-interface='docker0'

You might need root permissions to run that command.

After that I removed the interface with the command

ip link delete docker0

Then I purged the package and tried again.

sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .