Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
599 views
Welcome To Ask or Share your Answers For Others

1 Answer

You are looking check the flag --device

   --device=[]
      Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm)

Have a nice day!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...