From 86ebbe16de82933a916f67887aedd86d45a51882 Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Thu, 2 Jan 2020 14:28:51 +0530 Subject: [PATCH] remove host directory check Signed-off-by: Akhil Mohan --- daemon/container.go | 15 --------------- daemon/oci_linux.go | 5 ----- 2 files changed, 20 deletions(-) diff --git a/daemon/container.go b/daemon/container.go index ed4f80ae9e..cc785b59db 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -276,21 +276,6 @@ func validateHostConfig(hostConfig *containertypes.HostConfig, platform string) return nil } - if hostConfig.Privileged { - for _, deviceMapping := range hostConfig.Devices { - if deviceMapping.PathOnHost == deviceMapping.PathInContainer { - continue - } - if _, err := os.Stat(deviceMapping.PathInContainer); err != nil { - if os.IsNotExist(err) { - continue - } - return errors.Wrap(err, "error stating device path in container") - } - return errors.Errorf("container device path: %s must be different from any host device path for privileged mode containers", deviceMapping.PathInContainer) - } - } - if hostConfig.AutoRemove && !hostConfig.RestartPolicy.IsNone() { return errors.Errorf("can't create 'AutoRemove' container with restart policy") } diff --git a/daemon/oci_linux.go b/daemon/oci_linux.go index 7c5a65995a..874a1a371b 100644 --- a/daemon/oci_linux.go +++ b/daemon/oci_linux.go @@ -826,11 +826,6 @@ func WithDevices(daemon *Daemon, c *container.Container) coci.SpecOpts { logrus.WithField("container", c.ID).Warnf("path in container %s already exists in privileged mode", deviceMapping.PathInContainer) continue } - // check if the path exists in the container. need to create a device only if the - // path does not exists. - if _, err := os.Stat(deviceMapping.PathInContainer); !os.IsNotExist(err) { - return errors.Errorf("container device path: %s must be different from any host device path for privileged mode containers", deviceMapping.PathInContainer) - } d, _, err := oci.DevicesFromPath(deviceMapping.PathOnHost, deviceMapping.PathInContainer, "rwm") if err != nil { return err