From 4af9c309f0aa3424f1e4fcd796a3fb2488071c63 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Wed, 10 Apr 2013 18:23:34 -0700 Subject: [PATCH] Put the resolv.conf path in a variable instead of being hardcoded within lxc Upstream-commit: 1f9f5eed5d004395886b8e93cec9389332d8fded Component: engine --- components/engine/container.go | 13 +++++++------ components/engine/lxc_template.go | 2 +- components/engine/runtime.go | 6 +++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/components/engine/container.go b/components/engine/container.go index f180c7559b..a930cbd3e3 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -33,13 +33,14 @@ type Container struct { network *NetworkInterface NetworkSettings *NetworkSettings - SysInitPath string - cmd *exec.Cmd - stdout *writeBroadcaster - stderr *writeBroadcaster - stdin io.ReadCloser - stdinPipe io.WriteCloser + SysInitPath string + ResolvConfPath string + cmd *exec.Cmd + stdout *writeBroadcaster + stderr *writeBroadcaster + stdin io.ReadCloser + stdinPipe io.WriteCloser ptyMaster io.Closer runtime *Runtime diff --git a/components/engine/lxc_template.go b/components/engine/lxc_template.go index c6849cb0df..5ac62f52af 100644 --- a/components/engine/lxc_template.go +++ b/components/engine/lxc_template.go @@ -78,7 +78,7 @@ lxc.mount.entry = devpts {{$ROOTFS}}/dev/pts devpts newinstance,ptmxmode=0666,no lxc.mount.entry = {{.SysInitPath}} {{$ROOTFS}}/sbin/init none bind,ro 0 0 # In order to get a working DNS environment, mount bind (ro) the host's /etc/resolv.conf into the container -lxc.mount.entry = /etc/resolv.conf {{$ROOTFS}}/etc/resolv.conf none bind,ro 0 0 +lxc.mount.entry = {{.ResolvConfPath}} {{$ROOTFS}}/etc/resolv.conf none bind,ro 0 0 # drop linux capabilities (apply mainly to the user root in the container) diff --git a/components/engine/runtime.go b/components/engine/runtime.go index 24194f74ad..2dd419868f 100644 --- a/components/engine/runtime.go +++ b/components/engine/runtime.go @@ -82,6 +82,9 @@ func (runtime *Runtime) Create(config *Config) (*Container, error) { if config.Hostname == "" { config.Hostname = id[:12] } + + resolvConfPath := "/etc/resolv.conf" + container := &Container{ // FIXME: we should generate the ID here instead of receiving it as an argument Id: id, @@ -92,7 +95,8 @@ func (runtime *Runtime) Create(config *Config) (*Container, error) { Image: img.Id, // Always use the resolved image id NetworkSettings: &NetworkSettings{}, // FIXME: do we need to store this in the container? - SysInitPath: sysInitPath, + SysInitPath: sysInitPath, + ResolvConfPath: resolvConfPath, } container.root = runtime.containerRoot(container.Id) // Step 1: create the container directory.