Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nmcli in a docker container

i currently looking for running nmcli in a docker container

nmcli work great on my host but if i'm starting a privileged container nmcli does not work.

to start my container

sudo docker run --privileged --net host -it image_with_network-manager /bin/bash

and then running nmcli

nmcli dev wifi  => Error: Could not create NMClient object: Could not connect: No such file or directory

ifconfig inside my container is ok , i have eth0 and wlan0 of the host

like image 718
Maxime Krier Avatar asked Oct 04 '18 20:10

Maxime Krier


People also ask

Does nmcli work on a privileged container?

nmcli work great on my host but if i'm starting a privileged container nmcli does not work. Show activity on this post. docker run -d -it --privileged=true --net host --volume /var/run/dbus:/var/run/dbus [other args here] on Ubuntu18.04 and it works.

How to run the Dind image inside a docker container?

The dind image is baked with required utilities for Docker to run inside a docker container. Follow the steps to test the setup. Note: This requires your container to be run in privileged mode. Step 1: Create a container named dind-test with docker:dind image

Is Docker the only way to run containers?

But Docker is not the only way run containers. LXC is another way to run containers. Both LXC and Docker have roots in Linux. One of the reasons, the Docker container is more popular compared to competing containers such as LXC is its ability to load as “image” on host operating system in a simple and quick manner.

How to mount a docker container in interactive mode?

Step 1: Start Docker container in interactive mode mounting the docker.sock as volume. We will use the official docker image. Step 2: Once you are inside the container, execute the following docker command.


3 Answers

I run my container like this:

docker run -d -it --privileged=true --net host --volume /var/run/dbus:/var/run/dbus [other args here] on Ubuntu18.04 and it works.

Note: --volume /var/run/dbus:/var/run/dbus but not --volume /var/run/dbus, and the above volume sharing flag is used to share the outer system's bus. If you need the container to have its own bus, you will need to configure differently.

like image 67
weefwefwqg3 Avatar answered Nov 02 '22 22:11

weefwefwqg3


The thing about networkmanager is that it runs on dbus. I did the same thing (stracing and seeing what was needed)

Try mounting /var/run/dbus as a volume.

sudo docker run --privileged --net host -it --volume /var/run/dbus image_with_network-manager /bin/bash

like image 32
Adam Mischke vanities Avatar answered Nov 03 '22 00:11

Adam Mischke vanities


try in docker, this create own dbus in docker

docker run -it --net=host image_name
        
dbus-uuidgen > /var/lib/dbus/machine-id
mkdir -p /var/run/dbus
dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address
like image 40
Jozef Dominik Volák Avatar answered Nov 03 '22 00:11

Jozef Dominik Volák