cap_add needed to detect usb device

Hello–

I have a multicontainer app that is finally able to detect a Google coral connected through USB. The issue is that the first time it checks for the device it throws an error (I’d include, but suffice to say it doesn’t see the device connected on USB).

After the service restarts, it’s able to see and use the device correctly. Does anyone know the necessary cap_add permission to allow my container to see the connected USB device right away? Here are the relevant section of my docker-compose.yaml:

version: "2"
volumes:
  data-service:

services:
  data-service:
    build: ./data-service
    volumes:
        - "data-service:/data-srv"
  hardware-logic:
    build: ./hardware-logic
    cap_add:
      - "SYS_RAWIO"
      - "SYS_ADMIN"
      - "SYS_RESOURCE"
      - "SYS_MODULE"
    devices:
     - /dev/bus/usb
     - /dev/video0
     - /dev/ttyACM0
    labels:
      io.balena.features.balena-socket: '1'
      io.balena.features.kernel-modules: '1'
      io.balena.features.firmware: '1'
      io.balena.features.dbus: '1'
      io.balena.features.sysfs: '1'
      io.balena.features.procfs: '1'

Cheers

Sorry for the super delayed response here. Is this resolved for you yet. Also, did you already try cap_add with ALL option to see if that makes a difference.

You can enable persistent logging to compare logs 1:1 before and after restart to see if what changes. Ref: Configuration - Balena Documentation

Feel free to share logs of the device, we can help debug the same.

Regards,
Nitish

Hello Richard,

Do you still need help on this one?
Did you tried Nitish suggestion?
Did it helped?

You could also try adding ENV UDEV=1 to your Dockerfile and/or adding priviledge: true to the service in docker-compose

This is not enough:

I am definitively also experiencing problems with USB detection on a balena service container.

If I go to network_mode: host with my service, then everything works. However, I would like to run my service as an independent multicontainer (i.e. in bridge mode). And that’s when the problems start.

I am using the library usb-detection. I don’t think it is the libraries’s fault. I think there is still something wrong with udev inside the balena docker service.

I am running all this on a amd64 standard balena lib on an intel-based PC.

FROM balenalib/%%BALENA_MACHINE_NAME%%-node:16-run

Any idea what to do ?