| 1 | # ContainerSettings |
| 2 | |
| 3 | **Constructor** |
| 4 | |
| 5 | - `ContainerSettings(hstring imageName)` |
| 6 | - `imageName` must be non-empty. |
| 7 | |
| 8 | **Properties** |
| 9 | |
| 10 | - `ImageName()` / setter |
| 11 | - `Name()` / setter |
| 12 | - `InitProcess()` / setter |
| 13 | - `NetworkingMode()` / setter (`None` and `Bridged` only) |
| 14 | - `HostName()` / setter |
| 15 | - `DomainName()` / setter |
| 16 | - `EnableAutoRemove()` / setter |
| 17 | - `EnableGpu()` / setter |
| 18 | - `Privileged()` / setter |
| 19 | - `PortMappings()` / setter |
| 20 | - `Volumes()` / setter |
| 21 | - `NamedVolumes()` / setter |
| 22 | |
| 23 | **Important notes** |
| 24 | |
| 25 | - Collection setters reject `nullptr`. |
| 26 | - When converting to the C struct, null elements inside the collections are rejected. |
| 27 | |
| 28 | ```cpp |
| 29 | using namespace winrt::Windows::Foundation::Collections; |
| 30 | |
| 31 | ContainerSettings containerSettings{ L"demo-image:latest" }; |
| 32 | containerSettings.Name(L"demo-container"); |
| 33 | containerSettings.NetworkingMode( |
| 34 | winrt::box_value(ContainerNetworkingMode::Bridged) |
| 35 | .as<winrt::Windows::Foundation::IReference<ContainerNetworkingMode>>()); |
| 36 | containerSettings.HostName(L"demo-host"); |
| 37 | containerSettings.DomainName(L"localdomain"); |
| 38 | containerSettings.EnableAutoRemove(false); |
| 39 | containerSettings.EnableGpu(false); |
| 40 | containerSettings.Privileged(false); |
| 41 | |
| 42 | auto ports = single_threaded_vector<ContainerPortMapping>(); |
| 43 | ports.Append(ContainerPortMapping{ 8080, 80, PortProtocol::TCP }); |
| 44 | containerSettings.PortMappings(ports); |
| 45 | |
| 46 | auto volumes = single_threaded_vector<ContainerVolume>(); |
| 47 | volumes.Append(ContainerVolume{ L"C:\\src", L"/src", false }); |
| 48 | containerSettings.Volumes(volumes); |
| 49 | |
| 50 | auto namedVolumes = single_threaded_vector<ContainerNamedVolume>(); |
| 51 | namedVolumes.Append(ContainerNamedVolume{ L"cache", L"/cache", false }); |
| 52 | containerSettings.NamedVolumes(namedVolumes); |
| 53 | ``` |