This is the situation:

  • I have NetworkManager running on the host system.
  • I have systemd and dbus running in a privileged Docker container.
  • I want nmcli in the container to access the NetworkManager on the host system.
  • However: I also need to be able to access dbus services within the container as well.
  • The client in the container that accesses NetworkManager also accesses other Dbus services inside the container (like logind) so forwarding the entire bus to the container is not sufficient.

The goal is to have requests for NetworkManager routed to the parent dbus, and requests for anything else sent to the container dbus.

I've had a look at using xdg-dbus-proxy to implement this but it isn't possible using it.


1 Answer 1


How about you directly mount the DBUS socket of your host into the container ?

sudo docker run -v /run/user/1000/bus:/host-dbus.sock --rm -it your_container

That way all the DBUS traffic inside your container will remain untouched and to use nmcli, you just have to override the DBUS_SYSTEM_BUS_ADDRESS environment variable by prefixing it like so:

DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host-dbus.sock nmcli [something]

Instead of prefixing it everytime, you could also create a wrapper in /usr/local/bin with the following content:

export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host-dbus.sock
exec /usr/bin/nmcli "$@"

If your PATH is set correctly, it should have /usr/local/bin before /usr/bin. Everytime you call nmcli from the command line, it will use this wrapper instead of the real program, set the DBUS environment variable, and pass all your parameters to the original program. Don't forget to chmod +x /usr/local/bin/nmcli.

Please note that giving your container the ability to manage your host's network is really unsafe. You should not use that container for anything critical (like exposing a service to the internet). As long as it remains local for your own purpose, it's ok I guess.

  • 1
    The reason why this doesn't quite answer the question is this: some clients of NetworkManager and similar services need to access multiple services on dbus, some of which are in the system bus (like network manager) and some of which are in the container bus (like logind and KDE desktop). Thanks for the answer. Commented Mar 7, 2023 at 5:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .