Not able to access host system systemd service from docker container

  docker, dockerfile, systemctl, systemd, systemd-journald

I want to access host system systemd services, get the status of host system systemd service, restart the services.
Dockerfile:

FROM ubuntu:18.04 
RUN apt update RUN apt install -y init systemd systemd-sysv dbus dbus-user-session 
STOPSIGNAL SIGRTMIN+3 
ENTRYPOINT ["/sbin/init"]

Docker run command:

sudo docker run –name test-systemd-cont -d –cap-add=SYS_ADMIN -v
/sys/fs/cgroup/:/sys/fs/cgroup -v /proc:/proc -v
/usr/lib/systemd:/usr/lib/systemd -v /etc/systemd:/etc/systemd -v
/lib/systemd:/lib/systemd –tmpfs /run –tmpfs /run/lock –network host test-systemd

I am able to run container, But inside container if we check status of any host system systemd service it is giving status like dead or inactive, Although it is showing running in host system,
If we keep –privileged=true also giving chroot issue.
Please suggest on above issue.

Source: Docker Questions

LEAVE A COMMENT