Starting Docker Containers in unprivileged LXC on USB Hotplug

damian2000

New Member
Aug 3, 2023
2
1
3
Hello Proxmox Community,

I'm using Proxmox on my home server. I have several USB Devices (DVB-S Receiver, 3D Printer + Webcam) that I want to connect to my Server and use from Docker Containers (Running minisatip or octoprint). The USB Devices are turned off most of the time and are only turned on on demand. To access them, I have set up an unprivileged LXC Container with Debian 12, Docker and Docker Containers for the respective software. When starting everything manually, the docker containers can access the USB devices successfully.

What I would like to achieve is for the docker containers to be started and stopped automatically, whenever the corresponding USB device is plugged in/unplugged.

In the past, when I had everything running on plain Debian, I used a udev rule to run a script when a specific device was (un)plugged, essentially
Bash:
cd docker-dir; docker compose up
. On my Proxmox Setup, this does not work. udev in the unprivileged LXC container does not appear to process rules or in fact receive events (I forgot to note down the exact error messages - but they amounted to "udev can't do anything here"). udev on the host does process rules successfully - I'm already using this to adjust the permissions on the USB devices for access by the unprivileged container. However, trying to inject a call into the container by making a rule call
Code:
PUN+="pct exec 103 /dockerstuff/minisatip/up.sh"
(where up.sh contains the snippet from above and 103 is the lxc container in question) simply fails with an exit code 1 and no further information in either dmesg or syslog, not even which part of the call has failed.

I know that LXC and Docker are not a recommended combination. However, the bandwidth requirements of the DVB-S tuner far exceed what qemu can deliver for a VM on my hardware, so using a VM for this purpose is out of the question. I also have other USB devices in the system that are attached to several VMs (Zigbee Stick in one VM, low-performance USB Storage device in another), so making a VM and PCIe-Passthroughing the USB controller also is not an option for me.

I am now somewhat at a loss. How can I receive the Hotplug event anywhere on the machine and convert it into starting/stopping a docker container in a specific unprivileged LXC container?

Regards
Damian
 
  • Like
Reactions: malte669966
Hi to all of you.

I am a absolute new to the proxmox - Community.

I am experiencing the same issues. I got the 3D Printer working all right.
Once I turned it off and back on again I can´t communicate any more.

xxx@octoprint:~$ ls -al /dev/ttyUSB0
c--------- 0 nobody nogroup 188, 0 Aug 6 13:50 /dev/ttyUSB0

I have a feeling, that the permissions "get lost".
After the restart of the container ( with working 3D Printer) I get:

xxx@octoprint:~$
xxx@octoprint:~$ ls -al /dev/ttyUSB0
crw-rw-rw- 1 nobody nogroup 188, 0 Aug 6 19:58 /dev/ttyUSB0
xxx@octoprint:~$

and everything is fine again.

Cool if anybody would have an idea.

Regards
Malte
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!