docker doesn’t start in bionic (Unit docker.service is masked), if previously installed+removed in xenial

Bug #1844894 reported by Anders Kaseorg on 2019-09-21
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
docker.io (Ubuntu)
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://cloud-images.ubuntu.com/minimal/releases
$ lxc launch ubuntu-minimal:16.04 docker-test
$ 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.Version}}'
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.Version}}'

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
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/system/docker.service.
root@docker-test:~# systemctl start docker
root@docker-test:~# docker version -f '{{.Server.Version}}'
18.09.7

Michael Hudson-Doyle (mwhudson) wrote :

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+?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers