runconfig/hostconfig_windows.go
4f0d95fa
 package runconfig // import "github.com/docker/docker/runconfig"
c5e6a4b3
 
ee6c3580
 import (
 	"fmt"
a429ad1e
 
91e197d6
 	"github.com/docker/docker/api/types/container"
56f77d5a
 	"github.com/docker/docker/pkg/sysinfo"
7ac4232e
 )
15e35c44
 
5170a2c0
 // DefaultDaemonNetworkMode returns the default network stack the daemon should
 // use.
7ac4232e
 func DefaultDaemonNetworkMode() container.NetworkMode {
e8026d8a
 	return container.NetworkMode("nat")
f6ed5905
 }
ead62b59
 
 // IsPreDefinedNetwork indicates if a network is predefined by the daemon
 func IsPreDefinedNetwork(network string) bool {
e8026d8a
 	return !container.NetworkMode(network).IsUserDefined()
ead62b59
 }
ee6c3580
 
4af3389d
 // validateNetMode ensures that the various combinations of requested
ee6c3580
 // network settings are valid.
4af3389d
 func validateNetMode(c *container.Config, hc *container.HostConfig) error {
ee6c3580
 	if hc == nil {
 		return nil
 	}
040afcce
 
4af3389d
 	err := validateNetContainerMode(c, hc)
040afcce
 	if err != nil {
 		return err
 	}
 
 	if hc.NetworkMode.IsContainer() && hc.Isolation.IsHyperV() {
92291a73
 		return fmt.Errorf("Using the network stack of another container is not supported while using Hyper-V Containers")
ee6c3580
 	}
040afcce
 
ee6c3580
 	return nil
 }
 
4af3389d
 // validateIsolation performs platform specific validation of the
d4b07324
 // isolation in the hostconfig structure. Windows supports 'default' (or
a429ad1e
 // blank), 'process', or 'hyperv'.
4af3389d
 func validateIsolation(hc *container.HostConfig) error {
ee6c3580
 	// We may not be passed a host config, such as in the case of docker commit
 	if hc == nil {
 		return nil
 	}
 	if !hc.Isolation.IsValid() {
92291a73
 		return fmt.Errorf("Invalid isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation)
ee6c3580
 	}
 	return nil
 }
8df20663
 
4af3389d
 // validateQoS performs platform specific validation of the Qos settings
 func validateQoS(hc *container.HostConfig) error {
8df20663
 	return nil
 }
56f77d5a
 
4af3389d
 // validateResources performs platform specific validation of the resource settings
 func validateResources(hc *container.HostConfig, si *sysinfo.SysInfo) error {
56f77d5a
 	// We may not be passed a host config, such as in the case of docker commit
 	if hc == nil {
 		return nil
 	}
 	if hc.Resources.CPURealtimePeriod != 0 {
92291a73
 		return fmt.Errorf("Windows does not support CPU real-time period")
56f77d5a
 	}
 	if hc.Resources.CPURealtimeRuntime != 0 {
92291a73
 		return fmt.Errorf("Windows does not support CPU real-time runtime")
56f77d5a
 	}
 	return nil
 }
4af3389d
 
 // validatePrivileged performs platform specific validation of the Privileged setting
 func validatePrivileged(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.Privileged {
92291a73
 		return fmt.Errorf("Windows does not support privileged mode")
4af3389d
 	}
 	return nil
 }
6f7dc658
 
 // 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 {
92291a73
 		return fmt.Errorf("Windows does not support root filesystem in read-only mode")
6f7dc658
 	}
 	return nil
 }