Skip to content

Commit

Permalink
Merge pull request moby#1460 from dotcloud/patch1
Browse files Browse the repository at this point in the history
* Runtime: Mount /dev/shm as a tmpfs
  • Loading branch information
creack committed Aug 9, 2013
2 parents 2c4c10f + 18fc707 commit 8d1cd63
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
42 changes: 34 additions & 8 deletions graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,41 @@ func (graph *Graph) getDockerInitLayer() (string, error) {
// For all other errors, abort.
return "", err
}
// FIXME: how the hell do I break down this line in a way
// that is idiomatic and not ugly as hell?
if f, err := os.OpenFile(path.Join(initLayer, ".dockerinit"), os.O_CREATE|os.O_TRUNC, 0700); err != nil && !os.IsExist(err) {
// If file already existed, keep going.
// For all other errors, abort.
return "", err
} else {
f.Close()

for pth, typ := range map[string]string{
"/dev/pts": "dir",
"/dev/shm": "dir",
"/proc": "dir",
"/sys": "dir",
"/.dockerinit": "file",
"/etc/resolv.conf": "file",
// "var/run": "dir",
// "var/lock": "dir",
} {
if _, err := os.Stat(path.Join(initLayer, pth)); err != nil {
if os.IsNotExist(err) {
switch typ {
case "dir":
if err := os.MkdirAll(path.Join(initLayer, pth), 0755); err != nil {
return "", err
}
case "file":
if err := os.MkdirAll(path.Join(initLayer, path.Dir(pth)), 0755); err != nil {
return "", err
}

if f, err := os.OpenFile(path.Join(initLayer, pth), os.O_CREATE, 0755); err != nil {
return "", err
} else {
f.Close()
}
}
} else {
return "", err
}
}
}

// Layer is ready to use, if it wasn't before.
return initLayer, nil
}
Expand Down
2 changes: 1 addition & 1 deletion lxc_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ lxc.mount.entry = sysfs {{$ROOTFS}}/sys sysfs nosuid,nodev,noexec 0 0
lxc.mount.entry = devpts {{$ROOTFS}}/dev/pts devpts newinstance,ptmxmode=0666,nosuid,noexec 0 0
#lxc.mount.entry = varrun {{$ROOTFS}}/var/run tmpfs mode=755,size=4096k,nosuid,nodev,noexec 0 0
#lxc.mount.entry = varlock {{$ROOTFS}}/var/lock tmpfs size=1024k,nosuid,nodev,noexec 0 0
#lxc.mount.entry = shm {{$ROOTFS}}/dev/shm tmpfs size=65536k,nosuid,nodev,noexec 0 0
lxc.mount.entry = shm {{$ROOTFS}}/dev/shm tmpfs size=65536k,nosuid,nodev,noexec 0 0
# Inject docker-init
lxc.mount.entry = {{.SysInitPath}} {{$ROOTFS}}/.dockerinit none bind,ro 0 0
Expand Down

0 comments on commit 8d1cd63

Please sign in to comment.