[SOLVED] Use a USB webcam in a privileged container

rolfb

Member
Jan 4, 2022
12
7
8
Netherlands
Hi,

I'm running zoneminder in a (turnkey) privileged container. This goes fine for my 2 IP-cams.
But I'm not able to use my USBcam in the container / zoneminder.
I followed instructions I found here , but to no avail.
There are some things I am not sure about though.
The instructions declare a udev-rule with " SUBSYSTEMS=="usb", KERNEL=="hiddev*" " in it.
Not sure where he gets that values from, and what they should be for my webcam?

On the host (pve) I see
ls -l /dev/video* crwxrwxrwx 1 root video 81, 0 Feb 6 13:56 /dev/video0 crw-rw---- 1 root video 81, 1 Feb 6 13:56 /dev/video1
(I chmodded video0 to 777 by hand to open things up)

Looks fine to me?

In the container config file I added
lxc.cgroup.devices.allow: c 81:* rwm lxc.mount.entry: /dev/video0 dev/video0 none bind,optional,create=file

When rebooting the container, in dmesg I see:
root@zoneminder ~# dmesg |grep video [ 4.073679] videodev: Linux video capture interface: v2.00 [ 4.172793] usbcore: registered new interface driver uvcvideo [ 4.469148] ACPI: video: Video Device [GFX0] (multi-head: yes rom: no post: no) root@zoneminder ~# dmesg |grep 0819 #the ProductID of this webcam [ 1.858527] usb 1-4: New USB device found, idVendor=046d, idProduct=0819, bcdDevice= 0.10 [ 4.127316] usb 1-4: Found UVC 1.00 device <unnamed> (046d:0819) [ 4.172756] input: UVC Camera (046d:0819) as /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/input/input4

So, it seems the container has knowledge of the existence of the USBcam.
Also, there is a device-file:
root@zoneminder ~# ls -l /dev/video* crwxrwxrwx 1 root video 81, 0 Feb 6 13:56 /dev/video0

Yet, zoneminder is not able to use it:
Failed to open video device /dev/video0: Operation not permitted
(Settings within Zoneminder are identical to the same webcam succesfully connected to an earlier ZMinstall on bare metal)
Zoneminder is running with user www-data, that is memeber of group video:
root@zoneminder .../log/zm# groups www-data www-data : www-data video

Can anyone help with this?
If more info is needed please let me know.
 
OK, for anyone in the future looking for a similar answer:
in de lxc conf-file it should read:


lxc.cgroup2.devices.allow: c 81:* rwm lxc.mount.entry: /dev/video0 dev/video0 none bind,optional,create=file

(so, cgroup2, not cgroup)

cheers
 
  • Like
Reactions: bummer and Thorvi