[systemd-devel] Unable to run systemctl commands on the host from the container which was working till Ubuntu 16.04
Aravindhan Krishnan
aravindhank11 at gmail.com
Thu Jun 24 11:58:19 UTC 2021
Hi Folks,
Can someone help / guide on the above issue ?
Regards,
Aravindhan Krishnan...
On Thu, 17 Jun 2021 at 18:23, Aravindhan Krishnan <aravindhank11 at gmail.com>
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...
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210624/61f4b6ff/attachment-0001.htm>
More information about the systemd-devel
mailing list