Browse code

Always mount a /run tmpfs in the container

All modern distros set up /run to be a tmpfs, see for instance:
https://wiki.debian.org/ReleaseGoals/RunDirectory

Its a very useful place to store pid-files, sockets and other things
that only live at runtime and that should not be stored in the image.

This is also useful when running systemd inside a container, as it
will try to mount /run if not already mounted, which will fail for
non-privileged container.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)

Alexander Larsson authored on 2014/05/07 22:08:52
Showing 3 changed files
... ...
@@ -90,6 +90,7 @@ lxc.pivotdir = lxc_putold
90 90
 # We cannot mount them directly read-only, because that would prevent loading AppArmor profiles.
91 91
 lxc.mount.entry = proc {{escapeFstabSpaces $ROOTFS}}/proc proc nosuid,nodev,noexec 0 0
92 92
 lxc.mount.entry = sysfs {{escapeFstabSpaces $ROOTFS}}/sys sysfs nosuid,nodev,noexec 0 0
93
+lxc.mount.entry = tmpfs {{escapeFstabSpaces $ROOTFS}}/run tmpfs nosuid,nodev,noexec 0 0
93 94
 
94 95
 {{if .Tty}}
95 96
 lxc.mount.entry = {{.Console}} {{escapeFstabSpaces $ROOTFS}}/dev/console none bind,rw 0 0
... ...
@@ -254,6 +254,7 @@ func SetupInitLayer(initLayer string) error {
254 254
 		"/dev/pts":         "dir",
255 255
 		"/dev/shm":         "dir",
256 256
 		"/proc":            "dir",
257
+		"/run":             "dir",
257 258
 		"/sys":             "dir",
258 259
 		"/.dockerinit":     "file",
259 260
 		"/.dockerenv":      "file",
... ...
@@ -156,6 +156,7 @@ func newSystemMounts(rootfs, mountLabel string, mounts libcontainer.Mounts) []mo
156 156
 		{source: "sysfs", path: filepath.Join(rootfs, "sys"), device: "sysfs", flags: defaultMountFlags},
157 157
 		{source: "shm", path: filepath.Join(rootfs, "dev", "shm"), device: "tmpfs", flags: defaultMountFlags, data: label.FormatMountLabel("mode=1777,size=65536k", mountLabel)},
158 158
 		{source: "devpts", path: filepath.Join(rootfs, "dev", "pts"), device: "devpts", flags: syscall.MS_NOSUID | syscall.MS_NOEXEC, data: label.FormatMountLabel("newinstance,ptmxmode=0666,mode=620,gid=5", mountLabel)},
159
+		{source: "tmpfs", path: filepath.Join(rootfs, "run"), device: "tmpfs", flags: defaultMountFlags},
159 160
 	}
160 161
 
161 162
 	if len(mounts.OfType("devtmpfs")) == 1 {