From 307cd721644a67de4748b5ad38be30e3c9fe2622 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 9 Apr 2013 18:19:55 -0700 Subject: [PATCH] Handle data volumes mount points Upstream-commit: 8d9aaee60bf03397e51e8c84232a73fcb3baf36c Component: engine --- components/engine/container.go | 17 +++++++++++++++++ components/engine/lxc_template.go | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/components/engine/container.go b/components/engine/container.go index aaa8723662..4475fdac40 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -400,9 +400,26 @@ func (container *Container) Start() error { container.Config.MemorySwap = -1 } + // Create the requested volumes volumes + for volPath := range container.Config.Volumes { + if c, err := container.runtime.volumes.Create(nil, container, ""); err != nil { + return err + } else { + if err := os.MkdirAll(path.Join(container.RootfsPath(), volPath), 0755); err != nil { + return nil + } + root, err := c.root() + if err != nil { + return err + } + container.Config.Volumes[volPath] = root + } + } + if err := container.generateLXCConfig(); err != nil { return err } + params := []string{ "-n", container.Id, "-f", container.lxcConfigPath(), diff --git a/components/engine/lxc_template.go b/components/engine/lxc_template.go index 5ac62f52af..fd6461bb13 100644 --- a/components/engine/lxc_template.go +++ b/components/engine/lxc_template.go @@ -79,7 +79,11 @@ 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 = {{.ResolvConfPath}} {{$ROOTFS}}/etc/resolv.conf none bind,ro 0 0 - +{{if .Config.Volumes}} +{{range $T0, $T1 := .Config.Volumes}} +lxc.mount.entry = {{$T1}}/layer {{$ROOTFS}}/{{$T0}} none bind,rw 0 0 +{{end}} +{{end}} # drop linux capabilities (apply mainly to the user root in the container) lxc.cap.drop = audit_control audit_write mac_admin mac_override mknod setfcap setpcap sys_admin sys_boot sys_module sys_nice sys_pacct sys_rawio sys_resource sys_time sys_tty_config