Skip to content

Commit 6f7dc65

Browse files
author
John Howard
committed
Windows: Block read-only
Signed-off-by: John Howard <[email protected]>
1 parent afd7e2d commit 6f7dc65

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

runconfig/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ func DecodeContainerConfig(src io.Reader) (*container.Config, *container.HostCon
7979
return nil, nil, nil, err
8080
}
8181

82+
// Validate ReadonlyRootfs
83+
if err := validateReadonlyRootfs(hc); err != nil {
84+
return nil, nil, nil, err
85+
}
86+
8287
return w.Config, hc, w.NetworkingConfig, nil
8388
}
8489

runconfig/hostconfig_unix.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,8 @@ func validateResources(hc *container.HostConfig, si *sysinfo.SysInfo) error {
103103
func validatePrivileged(hc *container.HostConfig) error {
104104
return nil
105105
}
106+
107+
// validateReadonlyRootfs performs platform specific validation of the ReadonlyRootfs setting
108+
func validateReadonlyRootfs(hc *container.HostConfig) error {
109+
return nil
110+
}

runconfig/hostconfig_windows.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,15 @@ func validatePrivileged(hc *container.HostConfig) error {
8282
}
8383
return nil
8484
}
85+
86+
// validateReadonlyRootfs performs platform specific validation of the ReadonlyRootfs setting
87+
func validateReadonlyRootfs(hc *container.HostConfig) error {
88+
// We may not be passed a host config, such as in the case of docker commit
89+
if hc == nil {
90+
return nil
91+
}
92+
if hc.ReadonlyRootfs {
93+
return fmt.Errorf("invalid --read-only: Windows does not support this feature")
94+
}
95+
return nil
96+
}

0 commit comments

Comments
 (0)