github.com/ojongerius/docker@v1.11.2/libcontainerd/windowsoci/oci_windows.go (about) 1 package windowsoci 2 3 // This file contains the Windows spec for a container. At the time of 4 // writing, Windows does not have a spec defined in opencontainers/specs, 5 // hence this is an interim workaround. TODO Windows: FIXME @jhowardmsft 6 7 import ( 8 "fmt" 9 10 "github.com/docker/go-connections/nat" 11 ) 12 13 // WindowsSpec is the full specification for Windows containers. 14 type WindowsSpec struct { 15 Spec 16 17 // Windows is platform specific configuration for Windows based containers. 18 Windows Windows `json:"windows"` 19 } 20 21 // Spec is the base configuration for the container. It specifies platform 22 // independent configuration. This information must be included when the 23 // bundle is packaged for distribution. 24 type Spec struct { 25 26 // Version is the version of the specification that is supported. 27 Version string `json:"ociVersion"` 28 // Platform is the host information for OS and Arch. 29 Platform Platform `json:"platform"` 30 // Process is the container's main process. 31 Process Process `json:"process"` 32 // Root is the root information for the container's filesystem. 33 Root Root `json:"root"` 34 // Hostname is the container's host name. 35 Hostname string `json:"hostname,omitempty"` 36 // Mounts profile configuration for adding mounts to the container's filesystem. 37 Mounts []Mount `json:"mounts"` 38 } 39 40 // Windows contains platform specific configuration for Windows based containers. 41 type Windows struct { 42 // Resources contain information for handling resource constraints for the container 43 Resources *Resources `json:"resources,omitempty"` 44 // Networking contains the platform specific network settings for the container. 45 Networking *Networking `json:"networking,omitempty"` 46 // FirstStart is used for an optimization on first boot of Windows 47 FirstStart bool `json:"first_start,omitempty"` 48 // LayerFolder is the path to the current layer folder 49 LayerFolder string `json:"layer_folder,omitempty"` 50 // Layer paths of the parent layers 51 LayerPaths []string `json:"layer_paths,omitempty"` 52 // HvRuntime contains settings specific to Hyper-V containers, omitted if not using Hyper-V isolation 53 HvRuntime *HvRuntime `json:"hv_runtime,omitempty"` 54 } 55 56 // Process contains information to start a specific application inside the container. 57 type Process struct { 58 // Terminal indicates if stderr should NOT be attached for the container. 59 Terminal bool `json:"terminal"` 60 // ConsoleSize contains the initial h,w of the console size 61 InitialConsoleSize [2]int `json:"-"` 62 // User specifies user information for the process. 63 User User `json:"user"` 64 // Args specifies the binary and arguments for the application to execute. 65 Args []string `json:"args"` 66 // Env populates the process environment for the process. 67 Env []string `json:"env,omitempty"` 68 // Cwd is the current working directory for the process and must be 69 // relative to the container's root. 70 Cwd string `json:"cwd"` 71 } 72 73 // User contains the user information for Windows 74 type User struct { 75 User string `json:"user,omitempty"` 76 } 77 78 // Root contains information about the container's root filesystem on the host. 79 type Root struct { 80 // Path is the absolute path to the container's root filesystem. 81 Path string `json:"path"` 82 // Readonly makes the root filesystem for the container readonly before the process is executed. 83 Readonly bool `json:"readonly"` 84 } 85 86 // Platform specifies OS and arch information for the host system that the container 87 // is created for. 88 type Platform struct { 89 // OS is the operating system. 90 OS string `json:"os"` 91 // Arch is the architecture 92 Arch string `json:"arch"` 93 } 94 95 // Mount specifies a mount for a container. 96 type Mount struct { 97 // Destination is the path where the mount will be placed relative to the container's root. The path and child directories MUST exist, a runtime MUST NOT create directories automatically to a mount point. 98 Destination string `json:"destination"` 99 // Type specifies the mount kind. 100 Type string `json:"type"` 101 // Source specifies the source path of the mount. In the case of bind mounts 102 // this would be the file on the host. 103 Source string `json:"source"` 104 // Readonly specifies if the mount should be read-only 105 Readonly bool `json:"readonly"` 106 } 107 108 // HvRuntime contains settings specific to Hyper-V containers 109 type HvRuntime struct { 110 // ImagePath is the path to the Utility VM image for this container 111 ImagePath string `json:"image_path,omitempty"` 112 } 113 114 // Networking contains the platform specific network settings for the container 115 type Networking struct { 116 // TODO Windows TP5. The following three fields are for 'legacy' non- 117 // libnetwork networking through HCS. They can be removed once TP4 is 118 // no longer supported. Also remove in libcontainerd\client_windows.go, 119 // function Create(), and in daemon\oci_windows.go, function CreateSpec() 120 MacAddress string `json:"mac,omitempty"` 121 Bridge string `json:"bridge,omitempty"` 122 PortBindings nat.PortMap `json:"port_bindings,omitempty"` 123 // End of TODO Windows TP5. 124 125 // List of endpoints to be attached to the container 126 EndpointList []string `json:"endpoints,omitempty"` 127 } 128 129 // Storage contains storage resource management settings 130 type Storage struct { 131 // Specifies maximum Iops for the system drive 132 Iops *uint64 `json:"iops,omitempty"` 133 // Specifies maximum bytes per second for the system drive 134 Bps *uint64 `json:"bps,omitempty"` 135 // Sandbox size indicates the size to expand the system drive to if it is currently smaller 136 SandboxSize *uint64 `json:"sandbox_size,omitempty"` 137 } 138 139 // Memory contains memory settings for the container 140 type Memory struct { 141 // Memory limit (in bytes). 142 Limit *int64 `json:"limit,omitempty"` 143 // Memory reservation (in bytes). 144 Reservation *uint64 `json:"reservation,omitempty"` 145 } 146 147 // CPU contains information for cpu resource management 148 type CPU struct { 149 // Number of CPUs available to the container. This is an appoximation for Windows Server Containers. 150 Count *uint64 `json:"count,omitempty"` 151 // CPU shares (relative weight (ratio) vs. other containers with cpu shares). Range is from 1 to 10000. 152 Shares *uint64 `json:"shares,omitempty"` 153 // Percent of available CPUs usable by the container. 154 Percent *int64 `json:"percent,omitempty"` 155 } 156 157 // Network network resource management information 158 type Network struct { 159 // Bandwidth is the maximum egress bandwidth in bytes per second 160 Bandwidth *uint64 `json:"bandwidth,omitempty"` 161 } 162 163 // Resources has container runtime resource constraints 164 // TODO Windows containerd. This structure needs ratifying with the old resources 165 // structure used on Windows and the latest OCI spec. 166 type Resources struct { 167 // Memory restriction configuration 168 Memory *Memory `json:"memory,omitempty"` 169 // CPU resource restriction configuration 170 CPU *CPU `json:"cpu,omitempty"` 171 // Storage restriction configuration 172 Storage *Storage `json:"storage,omitempty"` 173 // Network restriction configuration 174 Network *Network `json:"network,omitempty"` 175 } 176 177 const ( 178 // VersionMajor is for an API incompatible changes 179 VersionMajor = 0 180 // VersionMinor is for functionality in a backwards-compatible manner 181 VersionMinor = 3 182 // VersionPatch is for backwards-compatible bug fixes 183 VersionPatch = 0 184 185 // VersionDev indicates development branch. Releases will be empty string. 186 VersionDev = "" 187 ) 188 189 // Version is the specification version that the package types support. 190 var Version = fmt.Sprintf("%d.%d.%d%s (Windows)", VersionMajor, VersionMinor, VersionPatch, VersionDev)