Re: Unable to run systemctl commands on the host from the container which was working till Ubuntu 16.04

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Folks,

Can someone help / guide on the above issue ?

Regards,
Aravindhan Krishnan...


On Thu, 17 Jun 2021 at 18:23, Aravindhan Krishnan <aravindhank11@xxxxxxxxx> wrote:
Hi Folks,

When the host OS is Ubuntu 16.04 or RHEL 7.x, the following command is working, helping us to run systemctl commands on the host from within the docker container:

# nsenter --mount=/hostroot/proc/1/ns/mnt -- systemctl start dummy.service

But in the newer host OS-es, Ubuntu 20.04 and RHEL 8.x, this doesn't work and we get the following error:

# nsenter --mount=/hostroot/proc/1/ns/mnt -- systemctl start dummy.service
Failed to connect to bus: No data available

I have attached a minimalistic example and commands to run and reproduce the issue:

Sample service which I wanted to start on the host, from the container:
# cat /etc/systemd/system/dummy.service
[Unit]
Description=dummy service

[Service]
ExecStart=/usr/bin/sleep infinity

Dockerfile of my container:
# cat Dockerfile
FROM ubuntu:20.04
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt update -y --fix-missing
RUN apt install -y util-linux
STOPSIGNAL SIGRTMIN+3
CMD [ "/bin/bash" ]

Build the image:
# docker build -t trial .

Delete any stale containers:
# docker rm -f trial

Run the image:
# docker run -it -d --net=host --privileged -v /:/hostroot -v /sys/fs/cgroup:/sys/fs/cgroup:ro --name trial trial

Reproduce the issue:
# docker exec -it trial bash
# nsenter --mount=/hostroot/proc/1/ns/mnt -- systemctl start dummy.service
Failed to connect to bus: No data available

I would like to know if there are any additional options or any docker run command that needs to be altered to get this working. 

Regards,
Aravindhan Krishnan...
_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux