From 30eff2720a110f3ece0e429ef1897a254f0d9e71 Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Fri, 9 Jan 2015 21:18:57 -0500 Subject: [PATCH] Properly handle containers which pre-date the resolv.conf update feature This fixes the container start issue for containers which were started on a daemon prior to the resolv.conf updater PR. The update code will now safely ignore these containers (given they don't have a sha256 hash to compare against) and will not attempt to update the resolv.conf through their lifetime. Docker-DCO-1.1-Signed-off-by: Phil Estes (github: estesp) --- daemon/container.go | 10 +++++++++- docs/sources/articles/networking.md | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/daemon/container.go b/daemon/container.go index 85e16e401a..8bbfb07b27 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -1057,7 +1057,15 @@ func (container *Container) updateResolvConf(updatedResolvConf []byte, newResolv //read the hash from the last time we wrote resolv.conf in the container hashBytes, err := ioutil.ReadFile(resolvHashFile) if err != nil { - return err + if !os.IsNotExist(err) { + return err + } + // backwards compat: if no hash file exists, this container pre-existed from + // a Docker daemon that didn't contain this update feature. Given we can't know + // if the user has modified the resolv.conf since container start time, safer + // to just never update the container's resolv.conf during it's lifetime which + // we can control by setting hashBytes to an empty string + hashBytes = []byte("") } //if the user has not modified the resolv.conf of the container since we wrote it last diff --git a/docs/sources/articles/networking.md b/docs/sources/articles/networking.md index f90b62ec7f..dac20af864 100644 --- a/docs/sources/articles/networking.md +++ b/docs/sources/articles/networking.md @@ -201,6 +201,13 @@ If the options (`--dns` or `--dns-search`) have been used to modify the default host configuration, then the replacement with an updated host's `/etc/resolv.conf` will not happen as well. +> **Note**: +> For containers which were created prior to the implementation of +> the `/etc/resolv.conf` update feature in Docker 1.5.0: those +> containers will **not** receive updates when the host `resolv.conf` +> file changes. Only containers created with Docker 1.5.0 and above +> will utilize this auto-update feature. + ## Communication between containers and the wider world