diff options
author | Max Goltzsche <max.goltzsche@gmail.com> | 2021-06-19 23:34:25 +0200 |
---|---|---|
committer | Max Goltzsche <max.goltzsche@gmail.com> | 2021-06-20 17:17:00 +0200 |
commit | 0fb165ed087c8ffc0ad01efab206c98bd27960f7 (patch) | |
tree | af1d859b7c3a77d5ff7bd0c4558dda61ff7362db /libpod/container_internal_linux.go | |
parent | d8cd20547831eb2074a9d45e9cd6999af0ab8a41 (diff) | |
download | podman-0fb165ed087c8ffc0ad01efab206c98bd27960f7.tar.gz podman-0fb165ed087c8ffc0ad01efab206c98bd27960f7.tar.bz2 podman-0fb165ed087c8ffc0ad01efab206c98bd27960f7.zip |
Fix systemd-resolved detection.
Previously podman failed when run in an environment where 127.0.0.53 is
the only nameserver but systemd-resolved is not used directly.
In practice this happened when podman was run within an alpine container
that used the host's network and the host was running systemd-resolved.
This fix makes podman ignore a file not found error when reading /run/systemd/resolve/resolv.conf.
Closes #10733
[NO TESTS NEEDED]
Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index c127cd3e6..25db3cff0 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -1661,9 +1661,13 @@ func (c *Container) generateResolvConf() (string, error) { // check if systemd-resolved is used, assume it is used when 127.0.0.53 is the only nameserver if len(ns) == 1 && ns[0] == "127.0.0.53" { // read the actual resolv.conf file for systemd-resolved - contents, err = ioutil.ReadFile("/run/systemd/resolve/resolv.conf") + resolvedContents, err := ioutil.ReadFile("/run/systemd/resolve/resolv.conf") if err != nil { - return "", errors.Wrapf(err, "detected that systemd-resolved is in use, but could not locate real resolv.conf") + if !os.IsNotExist(err) { + return "", errors.Wrapf(err, "detected that systemd-resolved is in use, but could not locate real resolv.conf") + } + } else { + contents = resolvedContents } } |