Skip to content

Commit 0c44a6c

Browse files
committed
fix mounting tmpfs
1 parent 21ac629 commit 0c44a6c

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

saturn/pkg/run/container.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,33 @@ func (d *DockerRuntime) CreateContainer(ctx context.Context, config *ContainerCo
9090
}
9191

9292
mounts := make([]mount.Mount, 0, len(config.Mounts))
93+
tmpfsMounts := make(map[string]string)
9394
for _, m := range config.Mounts {
9495
parts := strings.Split(m, ":")
9596
if len(parts) < 2 {
9697
return "", fmt.Errorf("invalid mount format: %s", m)
9798
}
9899

99-
mountType := mount.TypeBind
100+
// Handle tmpfs mounts
101+
if parts[0] == "tmpfs" {
102+
// Format: tmpfs:/path:options
103+
path := parts[1]
104+
opts := ""
105+
if len(parts) >= 3 {
106+
opts = parts[2]
107+
}
108+
tmpfsMounts[path] = opts
109+
continue
110+
}
111+
112+
// Handle bind mounts
100113
readOnly := false
101114
if len(parts) >= 3 && parts[2] == "ro" {
102115
readOnly = true
103116
}
104117

105118
mounts = append(mounts, mount.Mount{
106-
Type: mountType,
119+
Type: mount.TypeBind,
107120
Source: parts[0],
108121
Target: parts[1],
109122
ReadOnly: readOnly,
@@ -135,9 +148,13 @@ func (d *DockerRuntime) CreateContainer(ctx context.Context, config *ContainerCo
135148
CapAdd: config.CapabilitiesToAdd,
136149
}
137150

138-
if config.ReadOnlyRootFS {
139-
hostConfig.Tmpfs = map[string]string{
140-
"/tmp": "rw,noexec,nosuid,size=1g",
151+
// Merge tmpfs mounts
152+
if len(tmpfsMounts) > 0 || config.ReadOnlyRootFS {
153+
if hostConfig.Tmpfs == nil {
154+
hostConfig.Tmpfs = make(map[string]string)
155+
}
156+
for path, opts := range tmpfsMounts {
157+
hostConfig.Tmpfs[path] = opts
141158
}
142159
}
143160

0 commit comments

Comments
 (0)