func (container *Container) networkMounts() []execdriver.Mount {
var mounts []execdriver.Mount
- mode := "Z"
- if container.hostConfig.NetworkMode.IsContainer() {
- mode = "z"
- }
+ shared := container.hostConfig.NetworkMode.IsContainer()
if container.ResolvConfPath != "" {
- label.Relabel(container.ResolvConfPath, container.MountLabel, mode)
+ label.Relabel(container.ResolvConfPath, container.MountLabel, shared)
mounts = append(mounts, execdriver.Mount{
Source: container.ResolvConfPath,
Destination: "/etc/resolv.conf",
})
}
if container.HostnamePath != "" {
- label.Relabel(container.HostnamePath, container.MountLabel, mode)
+ label.Relabel(container.HostnamePath, container.MountLabel, shared)
mounts = append(mounts, execdriver.Mount{
Source: container.HostnamePath,
Destination: "/etc/hostname",
})
}
if container.HostsPath != "" {
- label.Relabel(container.HostsPath, container.MountLabel, mode)
+ label.Relabel(container.HostsPath, container.MountLabel, shared)
mounts = append(mounts, execdriver.Mount{
Source: container.HostsPath,
Destination: "/etc/hosts",
}
}
- if err := label.Relabel(bind.Source, container.MountLabel, bind.Relabel); err != nil {
+ shared := label.IsShared(bind.Relabel)
+ if err := label.Relabel(bind.Source, container.MountLabel, shared); err != nil {
return err
}
binds[bind.Destination] = true