From 39a036e24d026b62e49ce7ba00de8bafd38cd953 Mon Sep 17 00:00:00 2001 From: baude Date: Thu, 6 Dec 2018 13:56:57 -0600 Subject: bind mount /etc/resolv.conf|hosts in pods containers inside pods need to make sure they get /etc/resolv.conf and /etc/hosts bind mounted when network is expected Signed-off-by: baude --- libpod/container_internal_linux.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'libpod/container_internal_linux.go') diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index b540bbeb8..f9b0592f9 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -136,7 +136,14 @@ func (c *Container) prepare() (err error) { // cleanupNetwork unmounts and cleans up the container's network func (c *Container) cleanupNetwork() error { - if c.NetworkDisabled() { + if c.config.NetNsCtr != "" { + return nil + } + netDisabled, err := c.NetworkDisabled() + if err != nil { + return err + } + if netDisabled { return nil } if c.state.NetNS == nil { @@ -180,7 +187,6 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { if err := c.makeBindMounts(); err != nil { return nil, err } - // Check if the spec file mounts contain the label Relabel flags z or Z. // If they do, relabel the source directory and then remove the option. for _, m := range g.Mounts() { @@ -633,8 +639,12 @@ func (c *Container) makeBindMounts() error { if c.state.BindMounts == nil { c.state.BindMounts = make(map[string]string) } + netDisabled, err := c.NetworkDisabled() + if err != nil { + return err + } - if !c.NetworkDisabled() { + if !netDisabled { // Make /etc/resolv.conf if _, ok := c.state.BindMounts["/etc/resolv.conf"]; ok { // If it already exists, delete so we can recreate -- cgit v1.2.3-54-g00ecf