Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access camera inside docker container

Tags:

docker

I'm not sure that this is even possible, but is there a way to access my camera inside docker container? I'm not using external camera but built-in in my mac.

like image 493
elberth Avatar asked Nov 29 '15 17:11

elberth


2 Answers

I'm not sure that the flag volume (-v) is the best practice to do so.

According to the github of jfrazelle, docker engineer who wrote many Dockerfile and docker run for many graphical app such as chromium, skype, spotify, and so on, the flag and argument you should use is --device /dev/video0.

For quick test(tested on ubuntu), below code should give supported frame resolution of cameras:-

docker run --rm -it --entrypoint /bin/bash --device /dev/video0 jrottenberg/ffmpeg
ffmpeg -f video4linux2 -list_formats all -i /dev/video0
like image 130
Auzias Avatar answered Nov 03 '22 17:11

Auzias


You can try to forward your webcam device using -v flag

Something like

sudo docker run -d -p 55555:22 --privileged -v /dev/video0:/dev/video0 testimage

To list all devices attached to USB use lsusb ; to list all devices attached to PCI use lspci

like image 21
Hardik Juneja Avatar answered Nov 03 '22 15:11

Hardik Juneja