I'm trying to get hotplug working under Docker inside nodejs.
My nodejs test app:
// @ts-ignore
import usb from 'usb';
(async () => {
usb.on('attach', (device: any) => console.log("attache"));
usb.on('detach', (device: any) => console.log("detach"));
})();
My testbad container:
sudo docker run --rm -it --entrypoint bash -v /dev:/dev -v /var/run/udev:/var/run/udev -v $(pwd)/workdir:/app --privileged ubuntu:latest
There is some more packages required to get everything working (for now its bash script, end game is to have Dockerfile)
#!/bin/bash
apt update && apt-get install -y ca-certificates curl curl build-essential libgphoto2-dev libcups2-dev udev libudev-dev
curl -sL https://deb.nodesource.com/setup_13.x | bash -
apt -y install nodejs
npm i -g ts-node typescript
To get everything setup temporarily.
As it stands if i run udevadm monitor
a get events etc. But if I run my test script no events are recevied.
Also if i run my test app outside docker everything works as expected.
Have anybody tried this before?
Thanks