Browse code

Put the resolv.conf path in a variable instead of being hardcoded within lxc

Guillaume J. Charmes authored on 2013/04/11 10:23:34
Showing 3 changed files
... ...
@@ -33,13 +33,14 @@ type Container struct {
33 33
 	network         *NetworkInterface
34 34
 	NetworkSettings *NetworkSettings
35 35
 
36
-	SysInitPath string
37
-	cmd         *exec.Cmd
38
-	stdout      *writeBroadcaster
39
-	stderr      *writeBroadcaster
40
-	stdin       io.ReadCloser
41
-	stdinPipe   io.WriteCloser
42
-
36
+	SysInitPath    string
37
+	ResolvConfPath string
38
+
39
+	cmd       *exec.Cmd
40
+	stdout    *writeBroadcaster
41
+	stderr    *writeBroadcaster
42
+	stdin     io.ReadCloser
43
+	stdinPipe io.WriteCloser
43 44
 	ptyMaster io.Closer
44 45
 
45 46
 	runtime *Runtime
... ...
@@ -78,7 +78,7 @@ lxc.mount.entry = devpts {{$ROOTFS}}/dev/pts devpts newinstance,ptmxmode=0666,no
78 78
 lxc.mount.entry = {{.SysInitPath}} {{$ROOTFS}}/sbin/init none bind,ro 0 0
79 79
 
80 80
 # In order to get a working DNS environment, mount bind (ro) the host's /etc/resolv.conf into the container
81
-lxc.mount.entry = /etc/resolv.conf {{$ROOTFS}}/etc/resolv.conf none bind,ro 0 0
81
+lxc.mount.entry = {{.ResolvConfPath}} {{$ROOTFS}}/etc/resolv.conf none bind,ro 0 0
82 82
 
83 83
 
84 84
 # drop linux capabilities (apply mainly to the user root in the container)
... ...
@@ -82,6 +82,9 @@ func (runtime *Runtime) Create(config *Config) (*Container, error) {
82 82
 	if config.Hostname == "" {
83 83
 		config.Hostname = id[:12]
84 84
 	}
85
+
86
+	resolvConfPath := "/etc/resolv.conf"
87
+
85 88
 	container := &Container{
86 89
 		// FIXME: we should generate the ID here instead of receiving it as an argument
87 90
 		Id:              id,
... ...
@@ -92,7 +95,8 @@ func (runtime *Runtime) Create(config *Config) (*Container, error) {
92 92
 		Image:           img.Id, // Always use the resolved image id
93 93
 		NetworkSettings: &NetworkSettings{},
94 94
 		// FIXME: do we need to store this in the container?
95
-		SysInitPath: sysInitPath,
95
+		SysInitPath:    sysInitPath,
96
+		ResolvConfPath: resolvConfPath,
96 97
 	}
97 98
 	container.root = runtime.containerRoot(container.Id)
98 99
 	// Step 1: create the container directory.