与Docker共享设备(网络摄像头,USB驱动器等) [英] Sharing devices (webcam, USB drives, etc) with Docker
问题描述
我需要从我的Docker容器的主机Linux机器上的 / dev
中分享具体的设备。
I have a need to share specific devices from /dev
on my host Linux machine with my docker containers.
- 特权
标志适用于在 / dev
中共享当前 docker run
被调用,但任何随后添加或删除的设备都不会传播到容器中。
The --privileged
flag works for sharing any devices in /dev
that are present at the time docker run
is called, but any subsequently added or removed devices do not propagate into the container.
我试过 docker运行-v = / dev:/ dev ...
,但是结束了与/ dev / pts这样的文件的权限和所有权的关系,导致主机无法创建新的伪装终端。
I tried docker run -v=/dev:/dev ...
but that ended up screwing with the permissions and ownership of files like /dev/pts, leading to the host machine to not be able to create new psuedo-terminals.
我还尝试了 - 设备
标志,但这不允许你分享一个尚不存在的设备。
I also tried the --device
flag, but that doesn't allow you to share a device that doesn't yet exist.
最后,我尝试为 -v = / dev / video0:/ dev / video0
,但是如果/ dev / video0在运行前不存在,docker会在其中创建一个目录,网络摄像头在插入时不会占用/ dev / video0。
Finally, I tried sharing volumes for devices like -v=/dev/video0:/dev/video0
but if /dev/video0 doesn't exist before run, docker creates a directory there and a webcam will not take /dev/video0 when plugged in.
是有没有更好的方法来获得这个支持的功能?
Is there any better way to get this supported functionality?
推荐答案
你正在查看检查标志 - 设备
--device=[]
Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm)
有一个愉快的一天!
这篇关于与Docker共享设备(网络摄像头,USB驱动器等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!