I have a need to share specific devices from /dev
on my host Linux machine with my docker containers.
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.
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.
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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…