USB hardware and Cloudron Docker images
-
The question: Is it possible for me to have a Cloudron Docker container that grabs a USB serial device?
I have set up Home Assistant in a Cloudron container, and mosquitto (an MQTT broker) in another. They talk to each-other. They're friends.
I would like to have a container running zigbee2mqtt. This is a
node
app that talks to a USB zigbee adapter (I'm using this one).Is it possible for me to have a Cloudron Docker container that grabs that USB device?
If I was spinning this up outside of Cloudron, I'd use the
devices
tag in mydocker-compose.yml
. (This is the zigbee2mqtt compose, for reference.)@jadudm Devices are not exposed to containers. Usually, we add a flag in the manifest and expose devices to containers as needed. The idea being that in the future we can atleast "warn" or "inform" the user that the app wants to use the device. For example, emby uses the graphics card for vaapi api use. For example, https://git.cloudron.io/cloudron/box/-/blob/master/src/docker.js#L390
You can patch that specific function to add more devices there. If you can tell me what or how to expose the USB devices to the container, we can try to adjust the manifest accordingly.
-
@jadudm Devices are not exposed to containers. Usually, we add a flag in the manifest and expose devices to containers as needed. The idea being that in the future we can atleast "warn" or "inform" the user that the app wants to use the device. For example, emby uses the graphics card for vaapi api use. For example, https://git.cloudron.io/cloudron/box/-/blob/master/src/docker.js#L390
You can patch that specific function to add more devices there. If you can tell me what or how to expose the USB devices to the container, we can try to adjust the manifest accordingly.
@girish It usually depends on the device, but in this usecase (a zigbee usb stick), it's a TTY to USB device that has to be passed. I got something similar in my local HA install, and here's the relevant docker-compose bit:
devices: - '/dev/ttyUSB0:/dev/ttyUSB0'
I believe the equivalent
docker run
option would be:--device=/dev/ttyUSB0:/dev/ttyUSB0
-
@mehdi Ah, I see. Maybe we need
device
permission and some sort of device selector in the UI. -
@mehdi Ah, I see. Maybe we need
device
permission and some sort of device selector in the UI.@girish Right, device enumeration happens at the OS level, and it's not always consistent for silly kernel reasons.
From there one needs to be able to list all USB devices and have the user choose or add additional code to interrogate all USB devices for hints and choose automatically based on what the app is looking for (zigbee vs mouse/keyb).
-
@girish Right, device enumeration happens at the OS level, and it's not always consistent for silly kernel reasons.
From there one needs to be able to list all USB devices and have the user choose or add additional code to interrogate all USB devices for hints and choose automatically based on what the app is looking for (zigbee vs mouse/keyb).
@robi indeed, I guess additional complication is also that device names can change.
-
@girish yes, but generally only during major OS upgrades and new ways of handling of those driver subsystems.
@robi I think it also changes with the physical USB port that the device connects to (?)