| 1 | # <a name="windowsSpecificContainerConfiguration" />Windows-specific Container Configuration |
| 2 | |
| 3 | This document describes the schema for the [Windows-specific section](config.md#platform-specific-configuration) of the [container configuration](config.md). |
| 4 | The Windows container specification uses APIs provided by the Windows Host Compute Service (HCS) to fulfill the spec. |
| 5 | |
| 6 | ## <a name="configWindowsLayerFolders" />LayerFolders |
| 7 | |
| 8 | **`layerFolders`** (array of strings, REQUIRED) specifies a list of layer folders the container image relies on. The list is ordered from topmost layer to base layer with the last entry being the scratch. |
| 9 | `layerFolders` MUST contain at least one entry. |
| 10 | |
| 11 | ### Example |
| 12 | |
| 13 | ```json |
| 14 | "windows": { |
| 15 | "layerFolders": [ |
| 16 | "C:\\Layers\\layer2", |
| 17 | "C:\\Layers\\layer1", |
| 18 | "C:\\Layers\\layer-base", |
| 19 | "C:\\scratch", |
| 20 | ] |
| 21 | } |
| 22 | ``` |
| 23 | |
| 24 | ## <a name="configWindowsDevices" />Devices |
| 25 | |
| 26 | **`devices`** (array of objects, OPTIONAL) lists devices that MUST be available in the container. |
| 27 | |
| 28 | Each entry has the following structure: |
| 29 | |
| 30 | * **`id`** *(string, REQUIRED)* - specifies the device which the runtime MUST make available in the container. |
| 31 | * **`idType`** *(string, REQUIRED)* - tells the runtime how to interpret `id`. Today, Windows only supports a value of `class`, which identifies `id` as a [device interface class GUID][interfaceGUID]. |
| 32 | |
| 33 | [interfaceGUID]: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/overview-of-device-interface-classes |
| 34 | |
| 35 | ### Example |
| 36 | |
| 37 | ```json |
| 38 | "windows": { |
| 39 | "devices": [ |
| 40 | { |
| 41 | "id": "24E552D7-6523-47F7-A647-D3465BF1F5CA", |
| 42 | "idType": "class" |
| 43 | }, |
| 44 | { |
| 45 | "id": "5175d334-c371-4806-b3ba-71fd53c9258d", |
| 46 | "idType": "class" |
| 47 | } |
| 48 | ] |
| 49 | } |
| 50 | ``` |
| 51 | |
| 52 | ## <a name="configWindowsResources" />Resources |
| 53 | |
| 54 | You can configure a container's resource limits via the OPTIONAL `resources` field of the Windows configuration. |
| 55 | |
| 56 | ### <a name="configWindowsMemory" />Memory |
| 57 | |
| 58 | `memory` is an OPTIONAL configuration for the container's memory usage. |
| 59 | |
| 60 | The following parameters can be specified: |
| 61 | |
| 62 | * **`limit`** *(uint64, OPTIONAL)* - sets limit of memory usage in bytes. |
| 63 | |
| 64 | #### Example |
| 65 | |
| 66 | ```json |
| 67 | "windows": { |
| 68 | "resources": { |
| 69 | "memory": { |
| 70 | "limit": 2097152 |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | ``` |
| 75 | |
| 76 | ### <a name="configWindowsCpu" />CPU |
| 77 | |
| 78 | `cpu` is an OPTIONAL configuration for the container's CPU usage. |
| 79 | |
| 80 | The following parameters can be specified (mutually exclusive): |
| 81 | |
| 82 | * **`count`** *(uint64, OPTIONAL)* - specifies the number of CPUs available to the container. It represents the fraction of the configured processor `count` in a container in relation to the processors available in the host. The fraction ultimately determines the portion of processor cycles that the threads in a container can use during each scheduling interval, as the number of cycles per 10,000 cycles. |
| 83 | * **`shares`** *(uint16, OPTIONAL)* - limits the share of processor time given to the container relative to other workloads on the processor. The processor `shares` (`weight` at the platform level) is a value between 0 and 10,000. |
| 84 | * **`maximum`** *(uint16, OPTIONAL)* - determines the portion of processor cycles that the threads in a container can use during each scheduling interval, as the number of cycles per 10,000 cycles. Set processor `maximum` to a percentage times 100. |
| 85 | * **`affinity`** *(array of objects, OPTIONAL)* - specifies the set of CPU to affinitize for this container. |
| 86 | |
| 87 | Each entry has the following structure: |
| 88 | |
| 89 | Ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/miniport/ns-miniport-_group_affinity |
| 90 | |
| 91 | * **`mask`** *(uint64, REQUIRED)* - specifies the CPU mask relative to this CPU group. |
| 92 | * **`group`** *(uint32, REQUIRED)* - specifies the processor group this mask refers to, as returned by GetLogicalProcessorInformationEx. |
| 93 | |
| 94 | Ref: https://docs.microsoft.com/en-us/virtualization/api/hcs/schemareference#Container_Processor |
| 95 | |
| 96 | #### Example |
| 97 | |
| 98 | ```json |
| 99 | "windows": { |
| 100 | "resources": { |
| 101 | "cpu": { |
| 102 | "maximum": 5000 |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | ``` |
| 107 | |
| 108 | ### <a name="configWindowsStorage" />Storage |
| 109 | |
| 110 | `storage` is an OPTIONAL configuration for the container's storage usage. |
| 111 | |
| 112 | The following parameters can be specified: |
| 113 | |
| 114 | * **`iops`** *(uint64, OPTIONAL)* - specifies the maximum IO operations per second for the system drive of the container. |
| 115 | * **`bps`** *(uint64, OPTIONAL)* - specifies the maximum bytes per second for the system drive of the container. |
| 116 | * **`sandboxSize`** *(uint64, OPTIONAL)* - specifies the minimum size of the system drive in bytes. |
| 117 | |
| 118 | #### Example |
| 119 | |
| 120 | ```json |
| 121 | "windows": { |
| 122 | "resources": { |
| 123 | "storage": { |
| 124 | "iops": 50 |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | ``` |
| 129 | |
| 130 | ## <a name="configWindowsNetwork" />Network |
| 131 | |
| 132 | You can configure a container's networking options via the OPTIONAL `network` field of the Windows configuration. |
| 133 | |
| 134 | The following parameters can be specified: |
| 135 | |
| 136 | * **`endpointList`** *(array of strings, OPTIONAL)* - list of HNS (Host Network Service) endpoints that the container should connect to. |
| 137 | * **`allowUnqualifiedDNSQuery`** *(bool, OPTIONAL)* - specifies if unqualified DNS name resolution is allowed. |
| 138 | * **`DNSSearchList`** *(array of strings, OPTIONAL)* - comma separated list of DNS suffixes to use for name resolution. |
| 139 | * **`networkSharedContainerName`** *(string, OPTIONAL)* - name (ID) of the container that we will share with the network stack. |
| 140 | * **`networkNamespace`** *(string, OPTIONAL)* - name (ID) of the network namespace that will be used for the container. If a network namespace is specified no other parameter must be specified. |
| 141 | |
| 142 | ### Example |
| 143 | |
| 144 | ```json |
| 145 | "windows": { |
| 146 | "network": { |
| 147 | "endpointList": [ |
| 148 | "7a010682-17e0-4455-a838-02e5d9655fe6" |
| 149 | ], |
| 150 | "allowUnqualifiedDNSQuery": true, |
| 151 | "DNSSearchList": [ |
| 152 | "a.com", |
| 153 | "b.com" |
| 154 | ], |
| 155 | "networkSharedContainerName": "containerName", |
| 156 | "networkNamespace": "168f3daf-efc6-4377-b20a-2c86764ba892" |
| 157 | } |
| 158 | } |
| 159 | ``` |
| 160 | |
| 161 | ## <a name="configWindowsCredentialSpec" />Credential Spec |
| 162 | |
| 163 | You can configure a container's group Managed Service Account (gMSA) via the OPTIONAL `credentialSpec` field of the Windows configuration. |
| 164 | The `credentialSpec` is a JSON object whose properties are implementation-defined. |
| 165 | For more information about gMSAs, see [Active Directory Service Accounts for Windows Containers][gMSAOverview]. |
| 166 | For more information about tooling to generate a gMSA, see [Deployment Overview][gMSATooling]. |
| 167 | |
| 168 | |
| 169 | [gMSAOverview]: https://aka.ms/windowscontainers/manage-serviceaccounts |
| 170 | [gMSATooling]: https://aka.ms/windowscontainers/credentialspec-tools |
| 171 | |
| 172 | ## <a name="configWindowsServicing" />Servicing |
| 173 | |
| 174 | When a container terminates, the Host Compute Service indicates if a Windows update servicing operation is pending. |
| 175 | You can indicate that a container should be started in a mode to apply pending servicing operations via the OPTIONAL `servicing` field of the Windows configuration. |
| 176 | |
| 177 | ### Example |
| 178 | |
| 179 | ```json |
| 180 | "windows": { |
| 181 | "servicing": true |
| 182 | } |
| 183 | ``` |
| 184 | |
| 185 | ## <a name="configWindowsIgnoreFlushesDuringBoot" />IgnoreFlushesDuringBoot |
| 186 | |
| 187 | You can indicate that a container should be started in a mode where disk flushes are not performed during container boot via the OPTIONAL `ignoreFlushesDuringBoot` field of the Windows configuration. |
| 188 | |
| 189 | ### Example |
| 190 | |
| 191 | ```json |
| 192 | "windows": { |
| 193 | "ignoreFlushesDuringBoot": true |
| 194 | } |
| 195 | ``` |
| 196 | |
| 197 | ## <a name="configWindowsHyperV" />HyperV |
| 198 | |
| 199 | `hyperv` is an OPTIONAL field of the Windows configuration. |
| 200 | If present, the container MUST be run with Hyper-V isolation. |
| 201 | If omitted, the container MUST be run as a Windows Server container. |
| 202 | |
| 203 | The following parameters can be specified: |
| 204 | |
| 205 | * **`utilityVMPath`** *(string, OPTIONAL)* - specifies the path to the image used for the utility VM. |
| 206 | This would be specified if using a base image which does not contain a utility VM image. |
| 207 | If not supplied, the runtime will search the container filesystem layers from the bottom-most layer upwards, until it locates "UtilityVM", and default to that path. |
| 208 | |
| 209 | ### Example |
| 210 | |
| 211 | ```json |
| 212 | "windows": { |
| 213 | "hyperv": { |
| 214 | "utilityVMPath": "C:\\path\\to\\utilityvm" |
| 215 | } |
| 216 | } |
| 217 | ``` |