<div dir="ltr"><div class="gmail_default" style="font-family:comic sans ms,sans-serif">Hi Folks,<br clear="all"></div><div class="gmail_default" style="font-family:comic sans ms,sans-serif"><br></div><div class="gmail_default" style="font-family:comic sans ms,sans-serif">Can someone help / guide on the above issue ?</div><div class="gmail_default" style="font-family:comic sans ms,sans-serif"><br></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-family:'comic sans ms',sans-serif">Regards,</span><br></div><div><font face="comic sans ms, sans-serif">Aravindhan Krishnan...</font></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 17 Jun 2021 at 18:23, Aravindhan Krishnan <<a href="mailto:aravindhank11@gmail.com">aravindhank11@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:"comic sans ms",sans-serif">Hi Folks,<br></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif">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:</div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif"><br></div><div class="gmail_default"><font face="monospace"># nsenter --mount=/hostroot/proc/1/ns/mnt -- systemctl start dummy.service</font><br><br><font face="comic sans ms, sans-serif">But in the newer host OS-es, Ubuntu 20.04 and RHEL 8.x, this doesn't work and we get the </font>following<font face="comic sans ms, sans-serif"> error:</font><br><br><font face="monospace"># nsenter --mount=/hostroot/proc/1/ns/mnt -- systemctl start dummy.service<br>Failed to connect to bus: No data available</font></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif"><br></div><div class="gmail_default"><font face="comic sans ms, sans-serif">I have attached a minimalistic example and commands to run and reproduce the issue:</font></div><div class="gmail_default"><font face="comic sans ms, sans-serif"><br>Sample service which I wanted to start on the host, from the container:<br></font><font face="monospace"># cat /etc/systemd/system/dummy.service<br>[Unit]<br>Description=dummy service</font><br><font face="monospace">[Service]<br>ExecStart=/usr/bin/sleep infinity<br><br></font><font face="comic sans ms, sans-serif">Dockerfile of my container:</font><font face="monospace"><br># cat Dockerfile<br>FROM ubuntu:20.04<br>ENV TZ=UTC<br>RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone<br>RUN apt update -y --fix-missing<br>RUN apt install -y util-linux<br>STOPSIGNAL SIGRTMIN+3<br>CMD [ "/bin/bash" ]</font></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif"><br></div><div class="gmail_default"><font face="comic sans ms, sans-serif">Build the image:</font><br><font face="monospace"># docker build -t trial .</font></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif">Delete any stale containers:</div><div class="gmail_default"><font face="monospace"># docker rm -f trial</font><br></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif"><br></div><div class="gmail_default"><font face="comic sans ms, sans-serif">Run the image:</font><br><font face="monospace"># docker run -it -d --net=host --privileged -v /:/hostroot -v /sys/fs/cgroup:/sys/fs/cgroup:ro --name trial trial</font></div><div class="gmail_default" style="font-family:"comic sans ms",sans-serif"><br></div><div class="gmail_default"><font face="comic sans ms, sans-serif">Reproduce the issue:</font><br><font face="monospace"># docker exec -it trial bash</font></div><div class="gmail_default"><font face="monospace"># nsenter --mount=/hostroot/proc/1/ns/mnt -- systemctl start dummy.service<br>Failed to connect to bus: No data available<br></font><br><font face="comic sans ms, sans-serif">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. </font></div><div class="gmail_default"><font face="comic sans ms, sans-serif"><br></font></div><div><div dir="ltr"><div dir="ltr"><div><span style="font-family:"comic sans ms",sans-serif">Regards,</span><br></div><div><font face="comic sans ms, sans-serif">Aravindhan Krishnan...</font></div></div></div></div></div>
</blockquote></div>