docker-ce post installation configuration failure on Ubuntu 20.04

6,292

Solution 1

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.

Solution 2

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
Share:
6,292

Related videos on Youtube

unlockme
Author by

unlockme

Updated on September 18, 2022

Comments

  • unlockme
    unlockme over 1 year

    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.

  • SauloAlessandre
    SauloAlessandre over 3 years
    It happen on 20.04 too. Really thanks, turned off openconnect and the error not happen again.
  • jobima
    jobima over 3 years
    Same happended to me. Disable VPN before installing worked for me! Thanks
  • thsieh
    thsieh about 2 years
    this works for me. Thanks