Files
docker-cli/components/engine/daemon/daemon_linux.go
Mrunal Patel 58ef88608a Add support for sharing /dev/shm/ and /dev/mqueue between containers
This changeset creates /dev/shm and /dev/mqueue mounts for each container under
/var/lib/containers/<id>/ and bind mounts them into the container. When --ipc:container<id/name>
is used, then the /dev/shm and /dev/mqueue of the ipc container are used instead of creating
new ones for the container.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Upstream-commit: d88fe447df0e87b3a57f9d08b108b141dd72678c
Component: engine
2015-08-19 12:36:52 -04:00

45 lines
912 B
Go

package daemon
import (
"bufio"
"os"
"path/filepath"
"strings"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/mount"
)
// cleanupMounts umounts shm/mqueue mounts for old containers
func (daemon *Daemon) cleanupMounts() error {
logrus.Debugf("Cleaning up old shm/mqueue mounts: start.")
f, err := os.Open("/proc/self/mountinfo")
if err != nil {
return err
}
defer f.Close()
sc := bufio.NewScanner(f)
for sc.Scan() {
line := sc.Text()
fields := strings.Split(line, " ")
if strings.HasPrefix(fields[4], daemon.repository) {
mnt := fields[4]
mountBase := filepath.Base(mnt)
if mountBase == "mqueue" || mountBase == "shm" {
logrus.Debugf("Unmounting %+v", mnt)
if err := mount.Unmount(mnt); err != nil {
return err
}
}
}
}
if err := sc.Err(); err != nil {
return err
}
logrus.Debugf("Cleaning up old shm/mqueue mounts: done.")
return nil
}