-
Notifications
You must be signed in to change notification settings - Fork 114
Is it possible to detect usb devices in docker/balena container ? #123
Comments
@adamvx Are you passing the USB devices to the container? We won't be able to detect anything if you're just plugging and unplugging on the host without passing the USB device through. |
@MadLittleMods Of course, all host devices are passed to container through --privileged flag. As I said, I see that device in /dev directory of the container as I see it in host /dev directory when its connected. But no event is fired. Did you somehow managed to make it work ? |
@adamvx The way I test this library with linux is via a VirtualBox Ubuntu VM. The UI passthrough there is a bit clunky but the test suite does pass if I toggle the USB device through and off in the menus. |
@Adamx You have to expose udev sockets to the container, mounting /run/udev should help you out. |
No idea what you mean by I have the exact same problem when trying to use the library with an generic-amd64 standard BalenaOS Docker image i.e. Here is the steps I take: I make sure both are installed in my Docker.template file:
I also set the following in my Docker.template file:
And I make sure, the priviledge is set to true in my docker-compose.yml file:
But USB-detection is not working. It only works when running the code locally on my Mac. But it does not work inside the docker container. Inside my nodejs-code, I have:
What exactly is still wrong ? |
I found a temporary solution: If you set the following inside your Balena docker-compose.yml file, you can detect the USB device plugging: Set I also posted this in the Balena Forum as you can see here: Still, I am not quite happy with this solution since my multicontainer services are not allowed to constantly run on the same namespace as the HOST. Therefore What if the network_mode is |
Hi,
I tried to implement this library for my project running on balena but I was not able to make it run. It works on host but not in container even when its started with privileged flag.
I can provide an example to try it out.
First run the test container.
docker run -it --name test --privileged balenalib/raspberrypi4-64-debian-node:11-buster-build bash
Then create and new folder with
mkdir app
and inside it create new project withnpm init -y
Install required package with
install_packages libudev-dev
and install this librarynpm i usb-detection
. This will take some time because on this specific image are no pre-builded binariesThen create index.js
touch index.js
and paste there this snippet.Finally run project with
node index.js
and try to connect or disconnect any usb device. I was not able to detect any device even if its present in/dev
directory inside the container.Does anyone has been solving similar issue or is there some guide that I am not aware of ?
Thanks for the help.
The text was updated successfully, but these errors were encountered: