aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-01-10 15:58:18 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-11 12:39:06 +0000
commitdd0d35deb098b63f8c5be7ef9d8d63c16760221b (patch)
tree695d44a49d636e45e4121c9aecfb3d8c0e1cca06 /libpod
parente6be800ec633342aef656e0a2ed0bdc4519796d9 (diff)
downloadpodman-dd0d35deb098b63f8c5be7ef9d8d63c16760221b.tar.gz
podman-dd0d35deb098b63f8c5be7ef9d8d63c16760221b.tar.bz2
podman-dd0d35deb098b63f8c5be7ef9d8d63c16760221b.zip
Add support for shm-size.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #206 Approved by: TomSweeneyRedHat
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container.go29
-rw-r--r--libpod/options.go12
2 files changed, 36 insertions, 5 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 79fd5d42c..f3dd02cce 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -8,7 +8,6 @@ import (
"net"
"os"
"path/filepath"
- "strconv"
"syscall"
"time"
@@ -686,12 +685,32 @@ func (c *Container) Init() (err error) {
if c.config.CreateNetNS {
g.AddOrReplaceLinuxNamespace(spec.NetworkNamespace, c.state.NetNS.Path())
}
+ // Remove default /etc/shm mount
+ g.RemoveMount("/dev/shm")
// Mount ShmDir from host into container
- g.AddBindMount(c.config.ShmDir, "/dev/shm", []string{"rw"})
+ shmMnt := spec.Mount{
+ Type: "bind",
+ Source: c.config.ShmDir,
+ Destination: "/dev/shm",
+ Options: []string{"rw", "bind"},
+ }
+ g.AddMount(shmMnt)
// Bind mount resolv.conf
- g.AddBindMount(runDirResolv, "/etc/resolv.conf", []string{"rw"})
+ resolvMnt := spec.Mount{
+ Type: "bind",
+ Source: runDirResolv,
+ Destination: "/etc/resolv.conf",
+ Options: []string{"rw", "bind"},
+ }
+ g.AddMount(resolvMnt)
// Bind mount hosts
- g.AddBindMount(runDirHosts, "/etc/hosts", []string{"rw"})
+ hostsMnt := spec.Mount{
+ Type: "bind",
+ Source: runDirHosts,
+ Destination: "/etc/hosts",
+ Options: []string{"rw", "bind"},
+ }
+ g.AddMount(hostsMnt)
if c.config.User != "" {
if !c.state.Mounted {
@@ -1163,7 +1182,7 @@ func (c *Container) mountStorage() (err error) {
}
if !mounted {
- shmOptions := "mode=1777,size=" + strconv.Itoa(DefaultShmSize)
+ shmOptions := fmt.Sprintf("mode=1777,size=%d", c.config.ShmSize)
if err := unix.Mount("shm", c.config.ShmDir, "tmpfs", unix.MS_NOEXEC|unix.MS_NOSUID|unix.MS_NODEV,
label.FormatMountLabel(shmOptions, c.config.MountLabel)); err != nil {
return errors.Wrapf(err, "failed to mount shm tmpfs %q", c.config.ShmDir)
diff --git a/libpod/options.go b/libpod/options.go
index 199bf9ee9..cd1ad5eda 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -295,6 +295,18 @@ func WithShmDir(dir string) CtrCreateOption {
}
}
+// WithShmSize sets the size of /dev/shm tmpfs mount
+func WithShmSize(size int64) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+
+ ctr.config.ShmSize = size
+ return nil
+ }
+}
+
// WithSELinuxLabels sets the mount label for SELinux
func WithSELinuxLabels(processLabel, mountLabel string) CtrCreateOption {
return func(ctr *Container) error {