Browse Source

Windows: Block read-only

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard 8 năm trước cách đây
mục cha
commit
6f7dc65847
3 tập tin đã thay đổi với 22 bổ sung0 xóa
  1. 5 0
      runconfig/config.go
  2. 5 0
      runconfig/hostconfig_unix.go
  3. 12 0
      runconfig/hostconfig_windows.go

+ 5 - 0
runconfig/config.go

@@ -79,6 +79,11 @@ func DecodeContainerConfig(src io.Reader) (*container.Config, *container.HostCon
 		return nil, nil, nil, err
 	}
 
+	// Validate ReadonlyRootfs
+	if err := validateReadonlyRootfs(hc); err != nil {
+		return nil, nil, nil, err
+	}
+
 	return w.Config, hc, w.NetworkingConfig, nil
 }
 

+ 5 - 0
runconfig/hostconfig_unix.go

@@ -103,3 +103,8 @@ func validateResources(hc *container.HostConfig, si *sysinfo.SysInfo) error {
 func validatePrivileged(hc *container.HostConfig) error {
 	return nil
 }
+
+// validateReadonlyRootfs performs platform specific validation of the ReadonlyRootfs setting
+func validateReadonlyRootfs(hc *container.HostConfig) error {
+	return nil
+}

+ 12 - 0
runconfig/hostconfig_windows.go

@@ -82,3 +82,15 @@ func validatePrivileged(hc *container.HostConfig) error {
 	}
 	return nil
 }
+
+// validateReadonlyRootfs performs platform specific validation of the ReadonlyRootfs setting
+func validateReadonlyRootfs(hc *container.HostConfig) error {
+	// We may not be passed a host config, such as in the case of docker commit
+	if hc == nil {
+		return nil
+	}
+	if hc.ReadonlyRootfs {
+		return fmt.Errorf("invalid --read-only: Windows does not support this feature")
+	}
+	return nil
+}