diff options
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index ffb2f5b73..a1b4334fb 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -1412,7 +1412,8 @@ func (c *Container) generateResolvConf() (string, error) { // Determine the endpoint for resolv.conf in case it is a symlink resolvPath, err := filepath.EvalSymlinks(resolvConf) - if err != nil { + // resolv.conf doesn't have to exists + if err != nil && !os.IsNotExist(err) { return "", err } @@ -1422,7 +1423,8 @@ func (c *Container) generateResolvConf() (string, error) { } contents, err := ioutil.ReadFile(resolvPath) - if err != nil { + // resolv.conf doesn't have to exists + if err != nil && !os.IsNotExist(err) { return "", errors.Wrapf(err, "unable to read %s", resolvPath) } @@ -1550,9 +1552,13 @@ func (c *Container) getHosts() string { hosts += fmt.Sprintf("# used by slirp4netns\n%s\t%s %s\n", "10.0.2.100", c.Hostname(), c.config.Name) } else { hasNetNS := false + netNone := false for _, ns := range c.config.Spec.Linux.Namespaces { if ns.Type == spec.NetworkNamespace { hasNetNS = true + if ns.Path == "" && !c.config.CreateNetNS { + netNone = true + } break } } @@ -1564,6 +1570,9 @@ func (c *Container) getHosts() string { } hosts += fmt.Sprintf("127.0.1.1 %s\n", osHostname) } + if netNone { + hosts += fmt.Sprintf("127.0.1.1 %s\n", c.Hostname()) + } } } return hosts |