Wifi-connect Error: Cannot get the NetworkManager service state

Hello, I’m attempting to do a multi-container environment. I am getting this error when running the wifi-connect start.sh. Cannot get the NetworkManager service state

Cannot get the NetworkManager service state thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: D-Bus error: Failed to connect to socket /var/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.

This is my docker-compose

`version: ‘2’

services:
wifi-connect:
build: ./wifi-connect
expose:

  • “80”

gateway:
build: ./gateway
command: gateway:/mozilla-iot/gateway/run-app.sh
image: mozillaiot/gateway:arm
depends_on:

  • wifi-connect
    expose:
  • “8080”

volumes:
wifi-connect:
gateway:`

I also tried not exporting DBUS_SYSTEM_BUS_ADDRESS but I still have the same issue when I run bash start.sh in the service terminal.

@mowi22 I think you are probably missing the io.balena.features.dbus label on your service(s) so that the dbus socket is mounted to the host as mentioned in the docs here https://www.balena.io/docs/learn/develop/runtime/#dbus-communication-with-host-os and you can see all the label options and their defaults here https://www.balena.io/docs/reference/supervisor/docker-compose/#labels

Thank you, this worked

@mowi22 can you share your docker-compose file , i am still getting same error after adding io.balena.features.dbus labels

@yyogeshwar it should look like this:

version: '2'
services:
  mycontainer:
    build: ./mycontainer
    expose:
      - "80"
    labels:
      io.balena.features.dbus: '1'

Can you give us more info about the error that you are getting? Could you paste your docker-compose so that we can take a look?

Hi ,
Below is my docker-compose file and error output. I am running it on jetson tx2

Error screenshot

Hi,

Your error is highlighting that the host DBUS isn’t being used; the label exposes /host/run/dbus/system_bus_socket and your vnc-app service should use this instead of /var/run/dbus/system_bus_socket.

Change that in your implementation and it should be OK :+1:

I’m having the same problem. I can’t see anything I’m missing. I have the label and the DBUS_SYSTEM_BUS_ADDRESS environment variable. Can someone help me see what I’m missing?

This is the error I’m getting:

Attaching to config_wifi-connect_1
wifi-connect_1  | Starting WiFi Connect
wifi-connect_1  | Cannot get the NetworkManager service state
wifi-connect_1  | 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
wifi-connect_1  | note: Run with `RUST_BACKTRACE=1` for a backtrace.
config_wifi-connect_1 exited with code 101

This is my compose file:

version: "2.1"
services:
  wifi-connect:
    build:
      context: ~/git/wifi-connect2/
      dockerfile: wifi-dockerfile
    network_mode: "host"
    labels:
      io.balena.features.dbus: '1'
    environment:
      DBUS_SYSTEM_BUS_ADDRESS: "unix:path=/host/run/dbus/system_bus_socket"
    ports:
      - "80:80"
    cap_add:
      - NET_ADMIN
    privileged: true

Here is the Dockerfile. Am I pulling the wrong base image? I’m running on a Dell Ultrabook right now which is an amd64 system.

FROM balenalib/qemux86-64-ubuntu

RUN install_packages dnsmasq wireless-tools

WORKDIR /usr/src/app

RUN curl https://api.github.com/repos/balena-io/wifi-connect/releases/latest -s \
    | grep -hoP 'browser_download_url": "\K.*amd64\.tar\.gz' \
    | xargs -n1 curl -Ls \
    | tar -xvz -C /usr/src/app/

COPY scripts/start.sh .

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

Hi @james.carlson,

Can you please let us know more details about your setup? Since these configurations only work on a balena device with the supervisor installed.

@nghiant2710 What I’m trying to do is run wifi-connect on an AMD64 computer running Ubuntu 18.04. The computer is a Cincoze DA-1100. I’ve also been trying to run it on a Dell Ultrabook which is also an AMD64 system.

Do I even need to use Balena OS? All of the documentation I’ve found for running wifi-connect in docker involve using one of the Balena base images.

Hi James, you do not need to use a container with Docker to run WiFi Connect on you Ubuntu installation. You can just download the latest release archive from GitHub for amd64 and use it directly from inside the OS. Will that work for you? If you need to use Docker then you will need to expose D-Bus unix socket into the container.
Thanks,
Zahari