diff --git a/daemon/container_unix.go b/daemon/container_unix.go index 8015acaf23..ef9820cd51 100644 --- a/daemon/container_unix.go +++ b/daemon/container_unix.go @@ -1122,8 +1122,12 @@ func (container *Container) CleanupStorage() error { func (container *Container) networkMounts() []execdriver.Mount { var mounts []execdriver.Mount + mode := "Z" + if container.hostConfig.NetworkMode.IsContainer() { + mode = "z" + } if container.ResolvConfPath != "" { - label.SetFileLabel(container.ResolvConfPath, container.MountLabel) + label.Relabel(container.ResolvConfPath, container.MountLabel, mode) mounts = append(mounts, execdriver.Mount{ Source: container.ResolvConfPath, Destination: "/etc/resolv.conf", @@ -1132,7 +1136,7 @@ func (container *Container) networkMounts() []execdriver.Mount { }) } if container.HostnamePath != "" { - label.SetFileLabel(container.HostnamePath, container.MountLabel) + label.Relabel(container.HostnamePath, container.MountLabel, mode) mounts = append(mounts, execdriver.Mount{ Source: container.HostnamePath, Destination: "/etc/hostname", @@ -1141,7 +1145,7 @@ func (container *Container) networkMounts() []execdriver.Mount { }) } if container.HostsPath != "" { - label.SetFileLabel(container.HostsPath, container.MountLabel) + label.Relabel(container.HostsPath, container.MountLabel, mode) mounts = append(mounts, execdriver.Mount{ Source: container.HostsPath, Destination: "/etc/hosts",