Skip to content

Commit

Permalink
Always mount a /run tmpfs in the container
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
alexlarsson committed May 12, 2014
1 parent 30a40de commit 905795e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions daemon/execdriver/lxc/lxc_template.go
Expand Up @@ -90,6 +90,7 @@ lxc.pivotdir = lxc_putold
# We cannot mount them directly read-only, because that would prevent loading AppArmor profiles.
lxc.mount.entry = proc {{escapeFstabSpaces $ROOTFS}}/proc proc nosuid,nodev,noexec 0 0
lxc.mount.entry = sysfs {{escapeFstabSpaces $ROOTFS}}/sys sysfs nosuid,nodev,noexec 0 0
lxc.mount.entry = tmpfs {{escapeFstabSpaces $ROOTFS}}/run tmpfs nosuid,nodev,noexec 0 0
{{if .Tty}}
lxc.mount.entry = {{.Console}} {{escapeFstabSpaces $ROOTFS}}/dev/console none bind,rw 0 0
Expand Down
1 change: 1 addition & 0 deletions graph/graph.go
Expand Up @@ -254,6 +254,7 @@ func SetupInitLayer(initLayer string) error {
"/dev/pts": "dir",
"/dev/shm": "dir",
"/proc": "dir",
"/run": "dir",
"/sys": "dir",
"/.dockerinit": "file",
"/.dockerenv": "file",
Expand Down
1 change: 1 addition & 0 deletions pkg/libcontainer/mount/init.go
Expand Up @@ -156,6 +156,7 @@ func newSystemMounts(rootfs, mountLabel string, mounts libcontainer.Mounts) []mo
{source: "sysfs", path: filepath.Join(rootfs, "sys"), device: "sysfs", flags: defaultMountFlags},
{source: "shm", path: filepath.Join(rootfs, "dev", "shm"), device: "tmpfs", flags: defaultMountFlags, data: label.FormatMountLabel("mode=1777,size=65536k", mountLabel)},
{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)},
{source: "tmpfs", path: filepath.Join(rootfs, "run"), device: "tmpfs", flags: defaultMountFlags},
}

if len(mounts.OfType("devtmpfs")) == 1 {
Expand Down

0 comments on commit 905795e

Please sign in to comment.