Get WiFi psk by nmcli on container

I have installed wifi-connect inside the container and configured the WiFi of RPi Zero W successfully.

I want to get the WiFi passphrase of the currently connected AP from the container, but nmcli command is not working:

nmcli -s -g 802-11-wireless-security.psk connection show <SSID>

But I can see <SSID>.nmconnection file at /etc/NetworkManager/system-connections/ directory of the hostOS, which has the psk information I want to get.

How can I read the nmconnection file on hostOS from a container?

Hey Wester,

Do you have a single container or multiple containers running in the app?

If it is a multicontainer app, can you make sure you set the container as privileged and also the network mode to host and try again?

Yeah, multicontainer.
And of course, network mode is host and privileged is true

Hey there,

I’ve just run the following command in a container:

nmcli -s -f 802-11-wireless-security.psk connection show resin-wifi-01 

and got back the passphrase for my connection. I think you can’t specify the SSID, you have to specify the name of the system connection. I also had to issue:

export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socke

in order to get nmcli to work.

Hope this helps.


I think it depends on the version of nmcli whether you need to use the -g flag or my -f flag.

Ok, let me try.



Hmm, it still doesn’t work…
Here is my docker-compose.yml file:

version: "2.1"


        build: ./yokoso
        network_mode: "host"
        privileged: true
        restart: always
            io.balena.features.dbus: '1'
            io.balena.features.kernel-modules: '1'
            io.balena.features.firmware: '1'
            io.balena.features.supervisor-api: '1'
            - NET_ADMIN
            - SYS_RAWIO
            DBUS_SYSTEM_BUS_ADDRESS: "unix:path=/host/run/dbus/system_bus_socket"
            - "80:80"
            - 'yokoso-data:/yokoso'
# SSH into the yokoso container:
ubuntu@ubuntu-desktop:~$ sudo balena ssh yokoso
# Check if the environment is set correctly:
root@yokoso:/usr/src/app# printenv | grep DBUS
# Get connection list:
root@yokoso:/usr/src/app# nmcli -g NAME connection show
# Get psk of `resin-sample`:
root@yokoso:/usr/src/app# nmcli -s -g 802-11-wireless-security.psk connection show resin-sample

root@yokoso:/usr/src/app# nmcli -s -f 802-11-wireless-security.psk connection show resin-sample
802-11-wireless-security.psk:           --
root@yokoso:/usr/src/app# exit
Connection to closed.
# SSH into the hostOS:
ubuntu@ubuntu-desktop:~$ sudo balena ssh
Last login: Tue Oct 20 12:33:45 2020 from
# Well, it has `resin-wifi`??? instead of `resin-sample`?
root@yokoso:~# ls /etc/NetworkManager/system-connections/
README.ignore  resin-sample.ignore  resin-wifi
root@yokoso:~# ls /mnt/boot/system-connections/
README.ignore  resin-sample.ignore  resin-wifi

So, resin-wifi is actually used to configure the wifi, but I cannot see it on container? but seeing resin-sample instead?

What do you see for nmcli connection in the container ?