|
@@ -65,12 +65,11 @@ func (container *Container) NetworkMounts() []Mount {
|
|
|
if _, err := os.Stat(container.ResolvConfPath); err != nil {
|
|
|
logrus.Warnf("ResolvConfPath set to %q, but can't stat this filename (err = %v); skipping", container.ResolvConfPath, err)
|
|
|
} else {
|
|
|
- if !container.HasMountFor("/etc/resolv.conf") {
|
|
|
- label.Relabel(container.ResolvConfPath, container.MountLabel, shared)
|
|
|
- }
|
|
|
writable := !container.HostConfig.ReadonlyRootfs
|
|
|
if m, exists := container.MountPoints["/etc/resolv.conf"]; exists {
|
|
|
writable = m.RW
|
|
|
+ } else {
|
|
|
+ label.Relabel(container.ResolvConfPath, container.MountLabel, shared)
|
|
|
}
|
|
|
mounts = append(mounts, Mount{
|
|
|
Source: container.ResolvConfPath,
|
|
@@ -84,12 +83,11 @@ func (container *Container) NetworkMounts() []Mount {
|
|
|
if _, err := os.Stat(container.HostnamePath); err != nil {
|
|
|
logrus.Warnf("HostnamePath set to %q, but can't stat this filename (err = %v); skipping", container.HostnamePath, err)
|
|
|
} else {
|
|
|
- if !container.HasMountFor("/etc/hostname") {
|
|
|
- label.Relabel(container.HostnamePath, container.MountLabel, shared)
|
|
|
- }
|
|
|
writable := !container.HostConfig.ReadonlyRootfs
|
|
|
if m, exists := container.MountPoints["/etc/hostname"]; exists {
|
|
|
writable = m.RW
|
|
|
+ } else {
|
|
|
+ label.Relabel(container.HostnamePath, container.MountLabel, shared)
|
|
|
}
|
|
|
mounts = append(mounts, Mount{
|
|
|
Source: container.HostnamePath,
|
|
@@ -103,12 +101,11 @@ func (container *Container) NetworkMounts() []Mount {
|
|
|
if _, err := os.Stat(container.HostsPath); err != nil {
|
|
|
logrus.Warnf("HostsPath set to %q, but can't stat this filename (err = %v); skipping", container.HostsPath, err)
|
|
|
} else {
|
|
|
- if !container.HasMountFor("/etc/hosts") {
|
|
|
- label.Relabel(container.HostsPath, container.MountLabel, shared)
|
|
|
- }
|
|
|
writable := !container.HostConfig.ReadonlyRootfs
|
|
|
if m, exists := container.MountPoints["/etc/hosts"]; exists {
|
|
|
writable = m.RW
|
|
|
+ } else {
|
|
|
+ label.Relabel(container.HostsPath, container.MountLabel, shared)
|
|
|
}
|
|
|
mounts = append(mounts, Mount{
|
|
|
Source: container.HostsPath,
|
|
@@ -160,7 +157,18 @@ func (container *Container) ShmResourcePath() (string, error) {
|
|
|
// HasMountFor checks if path is a mountpoint
|
|
|
func (container *Container) HasMountFor(path string) bool {
|
|
|
_, exists := container.MountPoints[path]
|
|
|
- return exists
|
|
|
+ if exists {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ // Also search among the tmpfs mounts
|
|
|
+ for dest := range container.HostConfig.Tmpfs {
|
|
|
+ if dest == path {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false
|
|
|
}
|
|
|
|
|
|
// UnmountIpcMount uses the provided unmount function to unmount shm if it was mounted
|