docker doesn’t start in bionic (Unit docker.service is masked), if previously installed+removed in xenial
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
docker.io (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
If I install docker.io on xenial, remove it, upgrade to bionic, and install it again, then the docker service doesn’t start.
This is because the xenial docker.io postrm left docker.service and docker.socket masked (via an autogenerated deb-systemd-helper snippet), and the bionic docker.io postinst only unmasks docker.socket.
Reproducible test case with LXD:
• Create a xenial container:
$ lxc remote add --protocol simplestreams ubuntu-minimal https:/
$ lxc launch ubuntu-
$ lxc exec docker-test bash
root@docker-test:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
• Install docker.io:
root@docker-test:~# apt update
root@docker-test:~# apt -y install docker.io
root@docker-test:~# systemctl list-unit-files docker.socket docker.service
UNIT FILE STATE
docker.service enabled
docker.socket enabled
2 unit files listed.
root@docker-test:~# docker version -f '{{.Server.
18.09.7
• Remove docker.io:
root@docker-test:~# apt -y remove docker.io
root@docker-test:~# systemctl list-unit-files docker.socket docker.service
UNIT FILE STATE
docker.service masked
docker.socket masked
2 unit files listed.
• Upgrade to bionic:
root@docker-test:~# script /dev/null -c do-release-upgrade
…
Restart required
To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.
Continue [yN] y
Script done, file is /dev/null
$ lxc exec docker-test bash
root@docker-test:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
• Install docker.io:
root@docker-test:~# apt -y install docker.io
root@docker-test:~# systemctl list-unit-files docker.socket docker.service
UNIT FILE STATE
docker.service masked
docker.socket enabled
2 unit files listed.
root@docker-test:~# docker version -f '{{.Server.
Cannot connect to the Docker daemon at unix://
root@docker-test:~# systemctl start docker
Failed to start docker.service: Unit docker.service is masked.
• Workaround:
root@docker-test:~# systemctl unmask docker
Removed /etc/systemd/
root@docker-test:~# systemctl start docker
root@docker-test:~# docker version -f '{{.Server.
18.09.7
Thanks for the report, and congratulations on figuring out what was going on! I can see why the behaviour is as described on a very shallow level: xenial postrm masks both the service and socket units but the bionic postinst just unmasks the socket. Deeper than that, I really don't know. The way the service file is installed is different on xenial, it's installed via the .install file and maybe that makes dh_systemd do something different. Perhaps the pragmatic fix is to just explicitly insert "deb-systemd-helper unmask docker.service >/dev/null || true" into the postinst in bionic+?