Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Use tmpfs, versus mount
Browse files Browse the repository at this point in the history
  • Loading branch information
sargun committed May 8, 2018
1 parent b2dbc57 commit 85e6ab0
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions executor/runtime/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
docker "github.com/docker/docker/client"
"github.com/docker/go-units"
"github.com/ftrvxmtrx/fd"
Expand Down Expand Up @@ -231,7 +230,7 @@ type DockerRuntime struct { // nolint: golint
// NewDockerRuntime provides a Runtime implementation on Docker
func NewDockerRuntime(executorCtx context.Context, m metrics.Reporter, dockerCfg Config, cfg config.Config) (runtimeTypes.Runtime, error) {
log.Info("New Docker client, to host ", cfg.DockerHost)
client, err := docker.NewClient(cfg.DockerHost, "1.26", nil, map[string]string{})
client, err := docker.NewClient(cfg.DockerHost, "1.37", nil, map[string]string{})

if err != nil {
return nil, err
Expand Down Expand Up @@ -415,6 +414,8 @@ func (r *DockerRuntime) dockerConfig(c *runtimeTypes.Container, binds []string,
}

useInit := true

tmpFsMountString := fmt.Sprintf("rw,nosuid,nodev,noexec,relatime,size=%dk", (c.Resources.Mem/2)*KiB)
hostCfg := &container.HostConfig{
AutoRemove: false,
Privileged: false,
Expand All @@ -426,20 +427,25 @@ func (r *DockerRuntime) dockerConfig(c *runtimeTypes.Container, binds []string,
"net.ipv6.conf.default.disable_ipv6": "0",
"net.ipv6.conf.lo.disable_ipv6": "0",
},
Mounts: []mount.Mount{
{
Type: mount.TypeTmpfs,
Target: "/run",
ReadOnly: false,
TmpfsOptions: &mount.TmpfsOptions{
// we set a size mostly so processes get ENOSPACE instead of being shot by the cgroup OOM killer
// 50% of the container memory limit by default to leave some room for other things, tmpfs mounts
// by default on most distros have a size that is half of the host memory
SizeBytes: (c.Resources.Mem / 2) * MiB,
Mode: 01777,
},
},
Tmpfs: map[string]string{
"/run": tmpFsMountString,
},

//
//Mounts: []mount.Mount{
// {
// Type: mount.TypeTmpfs,
// Target: "/run",
// ReadOnly: false,
// TmpfsOptions: &mount.TmpfsOptions{
// // we set a size mostly so processes get ENOSPACE instead of being shot by the cgroup OOM killer
// // 50% of the container memory limit by default to leave some room for other things, tmpfs mounts
// // by default on most distros have a size that is half of the host memory
// SizeBytes: (c.Resources.Mem / 2) * MiB,
// Mode: 01777,
// },
// },
//},
Init: &useInit,
}
hostCfg.CgroupParent = r.pidCgroupPath
Expand Down

0 comments on commit 85e6ab0

Please sign in to comment.