Skip to content

Commit

Permalink
Don't error if resolv.conf does not exists
Browse files Browse the repository at this point in the history
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 containers#8089

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Paul Holzinger committed Oct 22, 2020
1 parent d340f85 commit f391849
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
}

Expand Down

0 comments on commit f391849

Please sign in to comment.