Is there a recommended way to view the currently active network connection in the Docker container (i.e. whether wired ethernet is used, which access point is used)? My team was doing this with nmcli before using Resin, but installing network-manager in the container is not recommended according to the documentation (also we tried it and it broke network connectivity on our devices).
have you tried looking at the nodes in /sys/class/net/?
Example with wired plugged in:
Thanks, I can see the network adapters and their status in that folder. I can’t find any info on the access point name that is used though, do you know if that is exposed anywhere in these folders?
I see that
iwlist can be used to get access point information in Linux. Is it OK to install these tools in a Resin container, or is it not recommended like
Those tools should be OK to install in the container. Alternatively, you could use the Network Manager D-Bus API to fetch the list of connections and see which is active. You can find the documentation for the API here:
Specifically, it seems that the properties on the
org.freedesktop.NetworkManager interface like
PrimaryConnection are what you are looking for.
I can confirm that after an
apt-get install wireless-tools I was able to use
Alternativelly, after an
apt-get install dbus I was able to query dbus with something like the following:
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \ dbus-send \ --system \ --print-reply \ --reply-timeout=2000 \ --type=method_call \ --dest=org.freedesktop.NetworkManager \ /org/freedesktop/NetworkManager \ org.freedesktop.DBus.Properties.GetAll \ string:"org.freedesktop.NetworkManager"
In case you also need some code for dbus parsing, you can take a look at the other dbus related repos