wifi-connect on balenaOS (RPI)

I am experiencing problems using wifi-connect as multi container image.
I built the image myself (not using balenacloud nor docker-compose build), the error is:

Starting WiFi Connect
Cannot get the NetworkManager service state
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: D-Bus error: Failed to connect to socket /host/run/dbus/system_bus_socket: No such file or directory (org.freedesktop.DBus.Error.FileNotFound)', /checkout/src/libcore/result.rs:906:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

the container is started with the following command, issued directly in the raspberry pi:

balena-engine run -d --name wifi \
--network host --restart unless-stopped \
-e DBUS_SYSTEM_BUS_ADDRESS="unix:path=/host/run/dbus/system_bus_socket" \
-l="io.balena.features.dbus='1'" \
--cap-add NET_ADMIN coderbot/wifi-connect:4.4.0

The Docker file from which the image is built:

FROM balenalib/rpi-debian:bullseye-20220819

ENV QEMU_CPU=max
RUN install_packages dnsmasq wireless-tools

WORKDIR /usr/src/app

ARG VERSION="4.4.0"
RUN curl -Ls "https://github.com/balena-io/wifi-connect/releases/download/v$VERSION/wifi-connect-v$VERSION-linux-rpi.tar.gz" \
  | tar -xvz -C  /usr/src/app/

COPY scripts/start.sh .

CMD ["bash", "start.sh"]

Any hints?

Hi

Can you please confirm which device you are using and the balenaOS and supervisor version running on your device?

also, from the snippets you shared, it seems you are running the container manually from the host os? is that correct? any particular reason for this workflow rather than our recommended deploy options?

thanks

Hello, yes I am running the container directly from the host OS, because I started with a disconnected balenaOS image (from the “getting started” section).
I am using the latest version of the balenaOS, running on a raspberry pi model 3 B.
I also tried the pre built balenablocks/wifi-connect image from docker hub with slightly different settings ( GitHub - balenablocks/wifi-connect: Easy WiFi setup for Linux devices from your mobile phone or laptop ), same problem: unable to access dbus socket.

Can you please try running the container as privileged and see if that works?

we can then look into additional capabilities required if any. also can you please try a more recent version? you are using 4.4.0 which is 2 years old and recent versions have security fixes

thanks

Hello, done both: privileged and version 4.4.6 as well as pre built image from balenablocks, which should be the most recent wifi-connect release.
Exactly same issue: dbus socket.

Ok, thanks

we’ll look into this further.

can you please enable support access for the device for us to investigate? you can share the uuid of the device in private chat.

thanks

I am running the container directly from the host OS, because I started with a disconnected balenaOS image (from the “getting started” section)

can you please elaborate on this? what do you mean disconnected image? do you mean it is no showing up on your balenaCloud dashboard? do you have an account?

thanks

Yes the device is not showing up, I think this is correct since the image is not linked to any account ( I followed this guide: balenaOS - Docs ).
Yes I do have an account (personal use), so I will try with an image linked to my account and follow the standard “push” procedure and see if the problem persists.

If you have balena cli installed you can use the balena join command as documented here: balena CLI Documentation - Balena Documentation

this way you want need to re-flash the device.

i suggest collecting logs from the device before doing any operations on it. this will help debug to an extent. you cab find more details here

let us know how it goes

Ok, I think I found out the problem, thanks to your advice.

  • joined the device to balenaCloud (balena-cli join -f org/fleet)
  • deployed the wifi-connect service via balenaCloud (balena-cli push fleet)
    With wifi-connet service working ok, I inspected the running container and found that I should not rely on labels to mount the dbus socket, instead I had to explicitly mount it via --mount option.
    So the working command is:
balena-engine run -d --name wifi 
 --network host \
 --restart unless-stopped  \
 --mount type=bind,source=/run/dbus,target=/host/run/dbus \
 -e DBUS_SYSTEM_BUS_ADDRESS="unix:path=/host/run/dbus/system_bus_socket" \
 --cap-add NET_ADMIN coderbot/wifi-connect:4.4.6

Again, many thanks for the support.
I want to say that using the balenaCloud service is pretty awesome, I probably don’t really need for my use case but it does solve a lot of device management tasks in a clever way.