Skip to content

Commit ea0457a

Browse files
committed
Add ReadOnly flag to run containers in readonly mode
This is needed for Automotive. Signed-off-by: Daniel J Walsh <[email protected]>
1 parent 24d7820 commit ea0457a

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

docs/containers.conf.5.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ is imposed.
241241

242242
Copy the content from the underlying image into the newly created volume when the container is created instead of when it is started. If `false`, the container engine will not copy the content until the container is started. Setting it to `true` may have negative performance implications.
243243

244+
**read_only**=true|false
245+
246+
Run all containers with root file system mounted read-only. Set to false by default.
247+
244248
**seccomp_profile**="/usr/share/containers/seccomp.json"
245249

246250
Path to the seccomp.json profile which is used as the default seccomp profile

pkg/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ type ContainersConfig struct {
194194
// performance implications.
195195
PrepareVolumeOnCreate bool `toml:"prepare_volume_on_create,omitempty"`
196196

197+
// ReadOnly causes engine to run all containers with root file system mounted read-only
198+
ReadOnly bool `toml:"read_only,omitempty"`
199+
197200
// SeccompProfile is the seccomp.json profile path which is used as the
198201
// default for the runtime.
199202
SeccompProfile string `toml:"seccomp_profile,omitempty"`

pkg/config/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var _ = Describe("Config", func() {
2929
gomega.Expect(defaultConfig.Containers.ApparmorProfile).To(gomega.Equal(apparmor.Profile))
3030
gomega.Expect(defaultConfig.Containers.BaseHostsFile).To(gomega.Equal(""))
3131
gomega.Expect(defaultConfig.Containers.PidsLimit).To(gomega.BeEquivalentTo(2048))
32+
gomega.Expect(defaultConfig.Containers.ReadOnly).To(gomega.BeFalse())
3233
gomega.Expect(defaultConfig.Engine.ServiceTimeout).To(gomega.BeEquivalentTo(5))
3334
gomega.Expect(defaultConfig.NetNS()).To(gomega.BeEquivalentTo("private"))
3435
gomega.Expect(defaultConfig.IPCNS()).To(gomega.BeEquivalentTo("shareable"))
@@ -443,6 +444,7 @@ image_copy_tmp_dir="storage"`
443444
gomega.Expect(config.Containers.LogDriver).To(gomega.Equal("journald"))
444445
gomega.Expect(config.Containers.LogTag).To(gomega.Equal("{{.Name}}|{{.ID}}"))
445446
gomega.Expect(config.Containers.LogSizeMax).To(gomega.Equal(int64(100000)))
447+
gomega.Expect(config.Containers.ReadOnly).To(gomega.BeTrue())
446448
gomega.Expect(config.Engine.ImageParallelCopies).To(gomega.Equal(uint(10)))
447449
gomega.Expect(config.Engine.PlatformToOCIRuntime).To(gomega.Equal(PlatformToOCIRuntimeMap))
448450
gomega.Expect(config.Engine.ImageDefaultFormat).To(gomega.Equal("v2s2"))

pkg/config/containers.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ default_sysctls = [
216216
#
217217
#prepare_volume_on_create = false
218218

219+
# Run all containers with root file system mounted read-only
220+
#
221+
# read_only: false
222+
219223
# Path to the seccomp.json profile which is used as the default seccomp profile
220224
# for the runtime.
221225
#

pkg/config/testdata/containers_override.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ apparmor_profile = "overridden-default"
44
log_driver = "journald"
55
log_tag="{{.Name}}|{{.ID}}"
66
log_size_max = 100000
7+
read_only=true
78

89
[engine]
910
image_parallel_copies=10

0 commit comments

Comments
 (0)