mirror of
https://github.com/moby/moby.git
synced 2025-12-07 19:42:23 +03:00
Merge pull request #10093 from crosbymichael/readonly-containers
Add --read-only for read only container rootfs
This commit is contained in:
@@ -3036,3 +3036,25 @@ func TestRunRestartMaxRetries(t *testing.T) {
|
||||
}
|
||||
logDone("run - test max-retries for --restart")
|
||||
}
|
||||
|
||||
func TestRunContainerWithWritableRootfs(t *testing.T) {
|
||||
defer deleteAllContainers()
|
||||
out, err := exec.Command(dockerBinary, "run", "--rm", "busybox", "touch", "/file").CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatal(string(out), err)
|
||||
}
|
||||
logDone("run - writable rootfs")
|
||||
}
|
||||
|
||||
func TestRunContainerWithReadonlyRootfs(t *testing.T) {
|
||||
defer deleteAllContainers()
|
||||
out, err := exec.Command(dockerBinary, "run", "--read-only", "--rm", "busybox", "touch", "/file").CombinedOutput()
|
||||
if err == nil {
|
||||
t.Fatal("expected container to error on run with read only error")
|
||||
}
|
||||
expected := "Read-only file system"
|
||||
if !strings.Contains(string(out), expected) {
|
||||
t.Fatalf("expected output from failure to contain %s but contains %s", expected, out)
|
||||
}
|
||||
logDone("run - read only rootfs")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user