From f391849c2282bba0b28f9bee5a7be5bff7bac623 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 22 Oct 2020 19:21:07 +0200 Subject: Don't error if resolv.conf does not exists If the resolv.conf file is empty we provide default dns servers. If the file does not exists we error and don't create the container. We should also provide the default entries in this case. This is also what docker does. Fixes #8089 Signed-off-by: Paul Holzinger --- libpod/container_internal_linux.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libpod') diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 2efe0d086..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) } -- cgit v1.2.3-54-g00ecf