moby: Deinstall and install of docker ce fails on ubuntu 18.04
Description
After successful docker-ce installation I uninstalled it. The second installation fails.
Steps to reproduce the issue:
I used vagrant to reproduce it:
vagrant init ubuntu/bionic64
vagrant up
vagrant ssh
Then I run the following commands:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get -y update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io
sudo apt-get -y purge docker-ce docker-ce-cli containerd.io
sudo apt-get -y install docker-ce docker-ce-cli containerd.io
Describe the results you received:
(I put the above commands in a shell script and run bash -x on that. But I get same failure if I enter commands directly).
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg
+ sudo apt-key add -
Warning: apt-key output should not be parsed (stdout is not a terminal)
OK
++ lsb_release -cs
+ sudo add-apt-repository 'deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable'
Hit:1 https://download.docker.com/linux/ubuntu bionic InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease
Reading package lists...
+ sudo apt-get -y update
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 https://download.docker.com/linux/ubuntu bionic InRelease
Hit:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Reading package lists...
+ sudo apt-get -y install docker-ce docker-ce-cli containerd.io
Reading package lists...
Building dependency tree...
Reading state information...
containerd.io is already the newest version (1.4.3-1).
docker-ce-cli is already the newest version (5:20.10.0~3-0~ubuntu-bionic).
docker-ce is already the newest version (5:20.10.0~3-0~ubuntu-bionic).
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up docker-ce (5:20.10.0~3-0~ubuntu-bionic) ...
Setting up docker-ce-rootless-extras (5:20.10.0~3-0~ubuntu-bionic) ...
W: APT had planned for dpkg to do more than it reported back (3 vs 7).
Affected packages: docker-ce:amd64
+ sudo apt-get -y purge docker-ce docker-ce-cli containerd.io
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
libltdl7 pigz
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
containerd.io* docker-ce* docker-ce-cli* docker-ce-rootless-extras*
0 upgraded, 0 newly installed, 4 to remove and 7 not upgraded.
After this operation, 445 MB disk space will be freed.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 60080 files and directories currently installed.)
Removing docker-ce-rootless-extras (5:20.10.0~3-0~ubuntu-bionic) ...
Removing docker-ce (5:20.10.0~3-0~ubuntu-bionic) ...
Warning: Stopping docker.service, but it can still be activated by:
docker.socket
Removing containerd.io (1.4.3-1) ...
Removing docker-ce-cli (5:20.10.0~3-0~ubuntu-bionic) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 59851 files and directories currently installed.)
Purging configuration files for docker-ce (5:20.10.0~3-0~ubuntu-bionic) ...
Purging configuration files for containerd.io (1.4.3-1) ...
Processing triggers for systemd (237-3ubuntu10.43) ...
Processing triggers for ureadahead (0.100.0-21) ...
+ sudo apt-get -y install docker-ce docker-ce-cli containerd.io
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
docker-ce-rootless-extras
Suggested packages:
aufs-tools cgroupfs-mount | cgroup-lite
Recommended packages:
slirp4netns
The following NEW packages will be installed:
containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras
0 upgraded, 4 newly installed, 0 to remove and 7 not upgraded.
Need to get 0 B/101 MB of archives.
After this operation, 445 MB of additional disk space will be used.
Selecting previously unselected package containerd.io.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 59846 files and directories currently installed.)
Preparing to unpack .../containerd.io_1.4.3-1_amd64.deb ...
Unpacking containerd.io (1.4.3-1) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../docker-ce-cli_5%3a20.10.0~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce-cli (5:20.10.0~3-0~ubuntu-bionic) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_5%3a20.10.0~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce (5:20.10.0~3-0~ubuntu-bionic) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../docker-ce-rootless-extras_5%3a20.10.0~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:20.10.0~3-0~ubuntu-bionic) ...
Setting up containerd.io (1.4.3-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-ce-cli (5:20.10.0~3-0~ubuntu-bionic) ...
Setting up docker-ce (5:20.10.0~3-0~ubuntu-bionic) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2020-12-14 22:27:40 UTC; 7ms ago
Docs: https://docs.docker.com
Process: 7435 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock [0;1;31m(code=exited, status=1/FAILURE)[0m
Main PID: 7435 (code=exited, status=1/FAILURE)
Dec 14 22:27:40 ubuntu-bionic systemd[1]: [0;1;39m[0;1;31m[0;1;39mdocker.service: Main process exited, code=exited, status=1/FAILURE[0m
Dec 14 22:27:40 ubuntu-bionic systemd[1]: [0;1;39m[0;1;31m[0;1;39mdocker.service: Failed with result 'exit-code'.[0m
Dec 14 22:27:40 ubuntu-bionic systemd[1]: [0;1;31m[0;1;39m[0;1;31mFailed to start Docker Application Container Engine.[0m
dpkg: error processing package docker-ce (--configure):
installed docker-ce package post-installation script subprocess returned error exit status 1
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
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.43) ...
Errors were encountered while processing:
docker-ce
docker-ce-rootless-extras
E: Sub-process /usr/bin/dpkg returned an error code (1)
Describe the results you expected:
I would expect that I could install docker a second time. I had also no success if I add docker-ce-rootless-extras to docker purge.
Additional information you deem important (e.g. issue happens only occasionally):
Looks similar https://github.com/docker/for-linux/issues/1154 (report of version included in repository).
Similar to https://github.com/moby/moby/issues/41781 but there docker installation succeed and the rootless scripts fails.
Output of docker version
:
(after running above installation steps)
Client: Docker Engine - Community
Version: 20.10.0
API version: 1.41
Go version: go1.13.15
Git commit: 7287ab3
Built: Tue Dec 8 18:59:53 2020
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Output of docker info
:
(after running above installation steps)
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.4.2-docker)
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
Additional environment details (AWS, VirtualBox, physical, etc.):
vagrant virtual box with ubuntu 18.04.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 10
- Comments: 49 (7 by maintainers)
Commits related to this issue
- ci: Fix docker installation and missing dependency for Ubuntu This PR adds a missing dependency for docker installation in order to avoid an issue like delaying package configuration, since apt-utils... — committed to GabyCT/tests-1 by GabyCT 3 years ago
- ci: Fix docker installation and missing dependency for Ubuntu This PR adds a missing dependency for docker installation in order to avoid an issue like delaying package configuration, since apt-utils... — committed to GabyCT/tests-1 by GabyCT 3 years ago
- ci: Fix docker installation and missing dependency for Ubuntu This PR adds a missing dependency for docker installation in order to avoid an issue like delaying package configuration, since apt-utils... — committed to GabyCT/tests-1 by GabyCT 3 years ago
@nik098: I had the same issue. In my case, VPN was the culprit. Turning off the VPN helped with the successful installation.
After playing around I solved my issue & now it re-installs 100% fine each time, so far. However the docker dev team should still fix this as running an extra command isn’t a permanent solution. Just doing a normal purge & install eachtime should work.
Solution is: before purging I run this:
Then next install it works fine. Repeat above step each time before purging & it re-installs fine each time. Tried 5 times in a row. Without stopping the socket first & directly purging then it re-installs every alternative time only.
I’ve solved.
Before a re-installation, I executed a below command.
And re-install.
A service status is OK.
Hope someone still needs help. I have done the following process to fix Ubuntu 20.04.2 LTS. Please add sudo if you are not root.
Using Ubuntu 20.04 bionic,
I had a exact same issue, turns out docker was not installed properly.
First completely remove docker using the following:
dpkg -l | grep -i docker
remove all the packages listed by running:
sudo apt-get purge -y <package_name>
also run the following commands:
Now reinstall the docker in the following order:
Install the containered.io package first.
None of the commands above have been able to solve the issue for me on Ubuntu 20.04.2 LTS
Here the output:
If I run after the failure
and restart system then following works (but a system restart looks only like a workaround):
If I run after this
it fails again with the same error.
As I said, it installs fine every alternative install so workaround is just purge & install again & it will work. But next purge/install it won’t, then next purge/install it will. This issue is only with Docker. I tried other apps like Elasticsearch & Nginx, and those don’t give error on followup installs so it can’t be my env. And I haven’t customized my OS; it is the basic LTS install the VPS provider images. Not a big issue since there is a work around.
Issue is replicable 100% of the time. To replicate repeat this (Ive also tried by having few minutes time gap too in between commands but same issue):
In journal this appears:
I had this exact same problem and what seems to have fixed it for me was running this:
sudo rm -rf /etc/systemd/system/docker.service.d
I also suggest running:
Purge everything docker afterwards and reinstall.
I reisntalled my server from scratch.
Found a thread on stack overflow for that error that mentions loading
ip_tables
worked; https://stackoverflow.com/a/22876662Also on that thread;
So might be worth trying if installation completes successfully after a restart of the machine 🤔
sudo rm -rf /etc/docker/daemon.json
Thank you SO much, I am running into Ansible automation issues due to this and was having a hell of a time tracking it down!
For me it was:
sudo systemctl unmask docker
sudo systemctl enable docker
sudo apt remove --purge docker docker.io containerd runc
sudo rm -Rf /etc/docker
I had the same problem and none of the advice given above helped. Ubuntu 20.04 LTS, latest versions of docker-ce. Installs and purging would both hang without even the ability to CTRL+C. I had to kill the process while it’s hanging to get it to stop and then do a dance of purge/kill in two terminals to get a purge to complete. Stopping the socket service would sometimes work as well but that itself would hang.
The only way for me to get it installed was to revert to the previous version of docker-ce and docker-ce-cli. In the process, i also lost all my containers (perhaps because i moved the /var/lib/docker dir away and back again later after one of the ideas floated here or there)
sudo apt-get install docker-ce=5:20.10.0~3-0~ubuntu-bionic docker-ce-cli=5:20.10.0~3-0~ubuntu-bionic containerd.io