mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-04 20:51:44 +00:00
Mount /dev in tmpfs for privileged containers
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/dotcloud/docker/daemon/execdriver/native/template"
|
||||
"github.com/dotcloud/docker/pkg/apparmor"
|
||||
"github.com/dotcloud/docker/pkg/libcontainer"
|
||||
"github.com/dotcloud/docker/pkg/libcontainer/mount/nodes"
|
||||
)
|
||||
|
||||
// createContainer populates and configures the container type with the
|
||||
@@ -34,8 +35,6 @@ func (d *driver) createContainer(c *execdriver.Command) (*libcontainer.Container
|
||||
if err := d.setPrivileged(container); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
container.Mounts = append(container.Mounts, libcontainer.Mount{Type: "devtmpfs"})
|
||||
}
|
||||
if err := d.setupCgroups(container, c); err != nil {
|
||||
return nil, err
|
||||
@@ -97,11 +96,16 @@ func (d *driver) createNetwork(container *libcontainer.Container, c *execdriver.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *driver) setPrivileged(container *libcontainer.Container) error {
|
||||
func (d *driver) setPrivileged(container *libcontainer.Container) (err error) {
|
||||
container.Capabilities = libcontainer.GetAllCapabilities()
|
||||
container.Cgroups.DeviceAccess = true
|
||||
|
||||
delete(container.Context, "restrictions")
|
||||
delete(container.DeviceNodes, "additional")
|
||||
|
||||
if container.DeviceNodes["required"], err = nodes.GetHostDeviceNodes(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if apparmor.IsEnabled() {
|
||||
container.Context["apparmor_profile"] = "unconfined"
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/dotcloud/docker/pkg/apparmor"
|
||||
"github.com/dotcloud/docker/pkg/libcontainer"
|
||||
"github.com/dotcloud/docker/pkg/libcontainer/cgroups"
|
||||
"github.com/dotcloud/docker/pkg/libcontainer/mount/nodes"
|
||||
)
|
||||
|
||||
// New returns the docker default configuration for libcontainer
|
||||
@@ -33,6 +34,10 @@ func New() *libcontainer.Container {
|
||||
DeviceAccess: false,
|
||||
},
|
||||
Context: libcontainer.Context{},
|
||||
DeviceNodes: map[string][]string{
|
||||
"required": nodes.DefaultNodes,
|
||||
"additional": {"fuse"},
|
||||
},
|
||||
}
|
||||
if apparmor.IsEnabled() {
|
||||
container.Context["apparmor_profile"] = "docker-default"
|
||||
|
||||
Reference in New Issue
Block a user