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.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'libpod/container.go') diff --git a/libpod/container.go b/libpod/container.go index b6155a809..b5346e581 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -1001,13 +1001,28 @@ func (c *Container) IsReadOnly() bool { } // NetworkDisabled returns whether the container is running with a disabled network -func (c *Container) NetworkDisabled() bool { +func (c *Container) NetworkDisabled() (bool, error) { + if c.config.NetNsCtr != "" { + container, err := c.runtime.LookupContainer(c.config.NetNsCtr) + if err != nil { + return false, err + } + return networkDisabled(container) + } + return networkDisabled(c) + +} + +func networkDisabled(c *Container) (bool, error) { + if c.config.CreateNetNS { + return false, nil + } if !c.config.PostConfigureNetNS { for _, ns := range c.config.Spec.Linux.Namespaces { if ns.Type == spec.NetworkNamespace { - return ns.Path == "" + return ns.Path == "", nil } } } - return false + return false, nil } -- cgit v1.2.3-54-g00ecf