Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit aff1c60

Browse files
committed
Add tmpfs
Signed-off-by: Josh Curl <[email protected]>
1 parent b6d71f3 commit aff1c60

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

config/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type ServiceConfigV1 struct {
5757
StdinOpen bool `yaml:"stdin_open,omitempty"`
5858
SecurityOpt []string `yaml:"security_opt,omitempty"`
5959
StopSignal string `yaml:"stop_signal,omitempty"`
60+
Tmpfs yaml.Stringorslice `yaml:"tmpfs,omitempty"`
6061
Tty bool `yaml:"tty,omitempty"`
6162
User string `yaml:"user,omitempty"`
6263
VolumeDriver string `yaml:"volume_driver,omitempty"`
@@ -116,6 +117,7 @@ type ServiceConfig struct {
116117
SecurityOpt []string `yaml:"security_opt,omitempty"`
117118
ShmSize yaml.StringorInt `yaml:"shm_size,omitempty"`
118119
StopSignal string `yaml:"stop_signal,omitempty"`
120+
Tmpfs yaml.Stringorslice `yaml:"tmpfs,omitempty"`
119121
VolumeDriver string `yaml:"volume_driver,omitempty"`
120122
Volumes *yaml.Volumes `yaml:"volumes,omitempty"`
121123
VolumesFrom []string `yaml:"volumes_from,omitempty"`

docker/service/convert.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ func Convert(c *config.ServiceConfig, ctx project.Context, clientFactory compose
234234
}
235235
}
236236

237+
tmpfs := map[string]string{}
238+
for _, path := range c.Tmpfs {
239+
tmpfs[path] = ""
240+
}
241+
237242
hostConfig := &container.HostConfig{
238243
VolumesFrom: volumesFrom,
239244
CapAdd: strslice.StrSlice(utils.CopySlice(c.CapAdd)),
@@ -256,6 +261,7 @@ func Convert(c *config.ServiceConfig, ctx project.Context, clientFactory compose
256261
RestartPolicy: *restartPolicy,
257262
ShmSize: int64(c.ShmSize),
258263
SecurityOpt: utils.CopySlice(c.SecurityOpt),
264+
Tmpfs: tmpfs,
259265
VolumeDriver: c.VolumeDriver,
260266
Resources: resources,
261267
}

docker/service/convert_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package service
22

33
import (
44
"path/filepath"
5+
"reflect"
56
"testing"
67

78
"github.com/docker/libcompose/config"
@@ -90,3 +91,16 @@ func TestStopSignal(t *testing.T) {
9091

9192
assert.Equal(t, "SIGTERM", cfg.StopSignal)
9293
}
94+
95+
func TestTmpfs(t *testing.T) {
96+
ctx := &ctx.Context{}
97+
sc := &config.ServiceConfig{
98+
Tmpfs: yaml.Stringorslice{"/run"},
99+
}
100+
_, hostCfg, err := Convert(sc, ctx.Context, nil)
101+
assert.Nil(t, err)
102+
103+
assert.True(t, reflect.DeepEqual(map[string]string{
104+
"/run": "",
105+
}, hostCfg.Tmpfs))
106+
}

0 commit comments

Comments
 (0)