docker-ce post installation subprocess never finishes

It appears that docker-ce is hanging on service start:

 \_ apt install docker-ce
     \_ /usr/bin/dpkg --status-fd 64 --configure --pending
         \_ /bin/sh /var/lib/dpkg/info/docker-ce.postinst configure
             \_ /bin/sh /usr/sbin/invoke-rc.d docker start
                 \_ systemctl start docker.service
                     \_ /bin/systemd-tty-ask-password-agent --watch

Killing systemctl start docker.service process should be enough:

sudo kill -9 $(ps aux | grep "systemctl start docker.service" | head -n 1 | awk '{print $2}')

check systemd jobs:

sudo systemctl list-jobs
    JOB UNIT           TYPE  STATE  
2831057 docker.service start running

if any docker job is running, kill it:

sudo systemctl kill docker.service

Make sure to verify that you don't have any overrides defined:

/etc/systemd/system/docker.service.d/

e.g. overriding command to (used in 17.03 release):

ExecStart=/usr/bin/docker daemon

instead of /usr/bin/dockerd. Before continuing be sure to kill any remaining docker process:

ps aux | grep "[d]ockerd"

stop remaining Docker daemon process (if there's any):

sudo kill -9 $(ps aux | grep "[d]ockerd" | head -n 1 | awk '{print $2}')

If you're upgrading from previous docker version (docker.io, docker-engine etc.) or just changing underlying file storage, it's safer to delete all docker data before installing new version.

sudo rm -rf /var/lib/docker
sudo apt install docker-ce

To fix broken installation, just run sudo dpkg --configure -a and docker.service should start.


I faced the same problem, here are all steps which I did to completely remove docker. I hope it'll help

Stoping docker services

service docker stop

Removing locks, after interupted installation

rm /var/lib/dpkg/lock

Restoring

dpkg --configure -a

If dpkg stuck, from different terminal stop the docker service

service docker stop 

Removing all docker packages and cleaning

apt-get remove docker docker-engine docker.io docker-ce
apt-get purge docker docker-engine docker.io docker-ce
apt-get autoremove
apt-get autoclean

Remove all docker related files

rm -rf /lib/systemd/system/docker.service
rm -rf /etc/docker
rm -rf /var/lib/docker
rm -rf /run/docker.sock
rm -rf /etc/systemd/system/docker.service.d

Optional, updating packages

apt-get update / upgrade / dist-upgrade

Rebooting

reboot