systemctl doesn't work when running from `docker run $image chroot` command (Bionic)

Bug #1904695 reported by Andrei Alymau
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

1) Tested on fresh installed system using http://old-releases.ubuntu.com/releases/bionic/ubuntu-18.04-server-amd64.iso image. The release of Ubuntu via 'lsb_release -rd'
Description: Ubuntu 18.04.4 LTS
Release: 18.04

2) The version of the systemd package via 'apt-cache policy systemd'
systemd:
  Installed: 237-3ubuntu10.33
  Candidate: 237-3ubuntu10.42
  Version table:
     237-3ubuntu10.42 500
        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
     237-3ubuntu10.38 500
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
 *** 237-3ubuntu10.33 100
        100 /var/lib/dpkg/status
     237-3ubuntu10 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

3) Steps to reproduce the problem
$ sudo su
$ apt update
$ apt install docker.io
$ docker pull ubuntu:latest
$ docker run -it -v /:/host_root:ro ubuntu:latest chroot /host_root/ systemctl -a

4) What you expected to happen: a list of all systemd units is expected to be displayed, e.g.
  UNIT LOAD ACTIVE SUB DESCRIPTION
  proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Auto
  dev-cdrom.device loaded active plugged VBOX_CD-ROM
  dev-disk-by\x2did-ata\x2dVBOX_CD\x2dROM_VB2\x2d01700376.device loaded active plugged VBOX_CD-ROM
....[cut out]....

5) What happened instead: get the following error message
Failed to connect to bus: No data available

6) The same steps tested on fresh installed Ubuntu Xenial OS using http://old-releases.ubuntu.com/releases/xenial/ubuntu-16.04.6-server-amd64.iso image.
And in this environment the `systemctl -a` command works well.
$ lsb_release -rd
Description: Ubuntu 16.04.6 LTS
Release: 16.04
$ apt-cache policy systemd
systemd:
  Installed: 229-4ubuntu21.16
  Candidate: 229-4ubuntu21.29
  Version table:
     229-4ubuntu21.29 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
     229-4ubuntu21.27 500
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
 *** 229-4ubuntu21.16 100
        100 /var/lib/dpkg/status
     229-4ubuntu4 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages

7) Additional notes: I tried to add `--privileged` options to `docker run` command but it didn't help.

Tags: systemctl
Revision history for this message
Andrei Alymau (apacrion) wrote :

I found a solution that works for me: it is needed to add option `--pid host` option to `docker run` command.

Balint Reczey (rbalint)
Changed in systemd (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.