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