diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-25 21:31:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 21:31:50 +0100 |
commit | e45c44208067f4ac26c5136842d5a17478f5234c (patch) | |
tree | deef90c9c3b502d137a64135ed0f125fbaeeb38b /libpod/container_internal_linux.go | |
parent | 6fc18e7d07e8263faca8341efb0220bf4be4f417 (diff) | |
parent | b87bdced1fa967846916b47cba5f093f72f3d11f (diff) | |
download | podman-e45c44208067f4ac26c5136842d5a17478f5234c.tar.gz podman-e45c44208067f4ac26c5136842d5a17478f5234c.tar.bz2 podman-e45c44208067f4ac26c5136842d5a17478f5234c.zip |
Merge pull request #2358 from rhatdan/namespace
Fix up handling of user defined network namespaces
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 3c0c5c3cf..f182b6bdf 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -757,8 +757,24 @@ func (c *Container) makeBindMounts() error { // generateResolvConf generates a containers resolv.conf func (c *Container) generateResolvConf() (string, error) { + resolvConf := "/etc/resolv.conf" + for _, ns := range c.config.Spec.Linux.Namespaces { + if ns.Type == spec.NetworkNamespace { + if ns.Path != "" && !strings.HasPrefix(ns.Path, "/proc/") { + definedPath := filepath.Join("/etc/netns", filepath.Base(ns.Path), "resolv.conf") + _, err := os.Stat(definedPath) + if err == nil { + resolvConf = definedPath + } else if !os.IsNotExist(err) { + return "", errors.Wrapf(err, "failed to stat %s", definedPath) + } + } + break + } + } + // Determine the endpoint for resolv.conf in case it is a symlink - resolvPath, err := filepath.EvalSymlinks("/etc/resolv.conf") + resolvPath, err := filepath.EvalSymlinks(resolvConf) if err != nil { return "", err } |