问题描述
我目前正在寻找在docker容器中运行nmcli
i currently looking for running nmcli in a docker container
nmcli在主机上运行良好,但是如果我要启动特权容器,nmcli将无法正常工作.
nmcli work great on my host but if i'm starting a privileged container nmcli does not work.
启动我的容器
sudo docker run --privileged --net host -it image_with_network-manager /bin/bash
然后运行nmcli
nmcli dev wifi => Error: Could not create NMClient object: Could not connect: No such file or directory
容器中的ifconfig正常,我拥有主机的eth0和wlan0
ifconfig inside my container is ok , i have eth0 and wlan0 of the host
推荐答案
我这样运行容器:
docker run -d -it --privileged=true --net host --volume /var/run/dbus:/var/run/dbus [other args here]
即可使用.
注意:--volume /var/run/dbus:/var/run/dbus
而不是--volume /var/run/dbus
,并且上面的音量共享标志用于共享 outer 系统的总线.如果您需要容器具有自己的总线,则需要进行其他配置.
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.
这篇关于docker容器中的nmcli的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!