How to check wifi status from within container

Is there a way to run: cat /sys/class/net/wlan0/operstate from within a container. If I run it from the hostOS terminal it gives the status of the wlan0 network (up/down, etc…). If I run it from a container terminal it returns: cat: /sys/class/net/wlan0/operstate: No such file or directory.

I would like to use this to monitor the status of wlan0 from a C application running inside a container.

Or, is there another preferred way to monitor wlan0 status from within a container?

Hi @etc3 I think to have access to /sys you need to run the container as privileged, then you should be able to query it just like you do in the hostOS. Alternatively you could probably use the dbus interface to NetworkManager to query the connection.

In docker-compose.yml this container does have privilaged: true however cat /sys/class/net/wlan0/operstate still does not work. I can issue dbus commands from within this container. Would you be able to provide an example dbus command that would be the simplest way to get the status of wlan0 on raspberrry pi?

Hey there, looking at I would probably use the /org/freedesktop/NetworkManager/ActiveConnection/ objects.

Thanks, I’ll give it a try