浏览代码

We want to allow the sharing of /dev from the host into the
container.

docker run -v /dev:/dev should stop mounting other default mounts in i
libcontainer otherwise directories and devices like /dev/ptx get mishandled.

We want to be able to run libvirtd for launching vms and it needs
access to the hosts /dev. This is a key componant of OpenStack.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)

Dan Walsh 10 年之前
父节点
当前提交
fe9fe1473c
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      daemon/execdriver/native/create.go

+ 4 - 0
daemon/execdriver/native/create.go

@@ -220,8 +220,12 @@ func (d *driver) setupMounts(container *configs.Config, c *execdriver.Command) e
 
 
 	// Filter out mounts that are overriden by user supplied mounts
 	// Filter out mounts that are overriden by user supplied mounts
 	var defaultMounts []*configs.Mount
 	var defaultMounts []*configs.Mount
+	_, mountDev := userMounts["/dev"]
 	for _, m := range container.Mounts {
 	for _, m := range container.Mounts {
 		if _, ok := userMounts[m.Destination]; !ok {
 		if _, ok := userMounts[m.Destination]; !ok {
+			if mountDev && strings.HasPrefix(m.Destination, "/dev/") {
+				continue
+			}
 			defaultMounts = append(defaultMounts, m)
 			defaultMounts = append(defaultMounts, m)
 		}
 		}
 	}
 	}