Do not set devices cgroup entries if in a user namespace
When in a non-initial user namespace you cannot update the devices cgroup whitelist (or blacklist). The kernel won't allow it. So detect that case and don't try. This is a step to being able to run docker/runc containers inside a user namespaced container. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
ce72f86a2b
commit
655f8ea808
|
@ -5,6 +5,7 @@ package fs
|
|||
import (
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
"github.com/opencontainers/runc/libcontainer/system"
|
||||
)
|
||||
|
||||
type DevicesGroup struct {
|
||||
|
@ -25,6 +26,10 @@ func (s *DevicesGroup) Apply(d *cgroupData) error {
|
|||
}
|
||||
|
||||
func (s *DevicesGroup) Set(path string, cgroup *configs.Cgroup) error {
|
||||
if system.RunningInUserNS() {
|
||||
return nil
|
||||
}
|
||||
|
||||
devices := cgroup.Resources.Devices
|
||||
if len(devices) > 0 {
|
||||
for _, dev := range devices {
|
||||
|
|
Loading…
Reference in New Issue