I'm trying to acess webcam from docker image. My permissions:
dockerx@85ca088a4e0c:~$ ls -la /dev/vid*
crwxrwxrwx+ 1 root 986 81, 0 May 29 08:52 /dev/video0
crwxrwxrwx+ 1 root 986 81, 1 May 29 08:52 /dev/video1
dockerx@85ca088a4e0c:~$ groups dockerx
dockerx : dockerx root video x2gouser
So, in theory, i have permissions to acess /dev/video*, but attempt to acess it (via vlc, for example) causes error:
dockerx@85ca088a4e0c:~$ vlc
VLC media player 3.0.8 Vetinari (revision 3.0.8-0-gf350b6b5a7)
[00005629e3774420] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-dockerx'
[00005629e3778390] main playlist: playlist is empty
[00007f5ca80010e0] v4l2 demux error: cannot open device '/dev/video0': Operation not permitted
[00007f5ca80010e0] v4l2 demux error: cannot open device '/dev/video0': Operation not permitted
[00007f5ca8003350] v4l2 stream error: cannot open device '/dev/video0': Operation not permitted
[00007f5ca000c800] v4l2 demux error: cannot open device '/dev/video1': Operation not permitted
[00007f5ca000c800] v4l2 demux error: cannot open device '/dev/video1': Operation not permitted
[00007f5ca000d130] v4l2 stream error: cannot open device '/dev/video1': Operation not permitted
QObject::~QObject: Timers cannot be stopped from another thread
Why can this happen?
Upd.: My Dockerfile, entrypoint.sh
UPD2. If you vote against, please spend one minute to say why. Thank you.
Add the privileged option docker run --privileged
. If it still doesn't work you may also consider mounting /dev/video
From the docs
by default a container is not allowed to access any devices, but a “privileged” container is given access to all devices (see the documentation on cgroups devices)
Also this answer is similar Docker: How to avoid Operation not permitted in Docker Container?