I need to restart the HostOS’s systemd service ModemManager from a container.
Running systemctl restart ModemManager.service from hostOS works fine but I cannot do that from the container.
I have dbus configured in the docker files and mmcli works in the container.
I used the D-Bus socket to restart a host systemd service from a container. Maybe there is a cleaner way of doing it, but for me, this works good enough.
If you mount the D-Bus socket into your container with a bind mount when you start your container using the following:
You can then use the dbus-send command-line tool that comes with dbus from within the container to talk to systemd on the host OS via the D-Bus socket that you mounted.
I created a bash function that accepts the name of the service you want to restart.