github.com/mforkel/docker-ce-i386@v17.12.1-ce-rc2+incompatible/components/engine/runconfig/hostconfig_windows.go (about)

     1  package runconfig
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/docker/docker/api/types/container"
     7  	"github.com/docker/docker/pkg/sysinfo"
     8  )
     9  
    10  // DefaultDaemonNetworkMode returns the default network stack the daemon should
    11  // use.
    12  func DefaultDaemonNetworkMode() container.NetworkMode {
    13  	return container.NetworkMode("nat")
    14  }
    15  
    16  // IsPreDefinedNetwork indicates if a network is predefined by the daemon
    17  func IsPreDefinedNetwork(network string) bool {
    18  	return !container.NetworkMode(network).IsUserDefined()
    19  }
    20  
    21  // validateNetMode ensures that the various combinations of requested
    22  // network settings are valid.
    23  func validateNetMode(c *container.Config, hc *container.HostConfig) error {
    24  	if hc == nil {
    25  		return nil
    26  	}
    27  
    28  	err := validateNetContainerMode(c, hc)
    29  	if err != nil {
    30  		return err
    31  	}
    32  
    33  	if hc.NetworkMode.IsContainer() && hc.Isolation.IsHyperV() {
    34  		return fmt.Errorf("Using the network stack of another container is not supported while using Hyper-V Containers")
    35  	}
    36  
    37  	return nil
    38  }
    39  
    40  // validateIsolation performs platform specific validation of the
    41  // isolation in the hostconfig structure. Windows supports 'default' (or
    42  // blank), 'process', or 'hyperv'.
    43  func validateIsolation(hc *container.HostConfig) error {
    44  	// We may not be passed a host config, such as in the case of docker commit
    45  	if hc == nil {
    46  		return nil
    47  	}
    48  	if !hc.Isolation.IsValid() {
    49  		return fmt.Errorf("Invalid isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation)
    50  	}
    51  	return nil
    52  }
    53  
    54  // validateQoS performs platform specific validation of the Qos settings
    55  func validateQoS(hc *container.HostConfig) error {
    56  	return nil
    57  }
    58  
    59  // validateResources performs platform specific validation of the resource settings
    60  func validateResources(hc *container.HostConfig, si *sysinfo.SysInfo) error {
    61  	// We may not be passed a host config, such as in the case of docker commit
    62  	if hc == nil {
    63  		return nil
    64  	}
    65  	if hc.Resources.CPURealtimePeriod != 0 {
    66  		return fmt.Errorf("Windows does not support CPU real-time period")
    67  	}
    68  	if hc.Resources.CPURealtimeRuntime != 0 {
    69  		return fmt.Errorf("Windows does not support CPU real-time runtime")
    70  	}
    71  	return nil
    72  }
    73  
    74  // validatePrivileged performs platform specific validation of the Privileged setting
    75  func validatePrivileged(hc *container.HostConfig) error {
    76  	// We may not be passed a host config, such as in the case of docker commit
    77  	if hc == nil {
    78  		return nil
    79  	}
    80  	if hc.Privileged {
    81  		return fmt.Errorf("Windows does not support privileged mode")
    82  	}
    83  	return nil
    84  }
    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("Windows does not support root filesystem in read-only mode")
    94  	}
    95  	return nil
    96  }