aspire icon indicating copy to clipboard operation
aspire copied to clipboard

Windows Container Support

Open gerneio opened this issue 2 years ago • 5 comments
trafficstars

If I switch docker desktop to Windows containers, I can get Aspire to build containers under windows runtime, however looks like some annotations are not fully supported or configured properly to work with WCOW. For example, port bindings:

builder.AddContainer("test", "mcr.microsoft.com/windows/nanoserver", "ltsc2022")
    .WithServiceBinding(containerPort: 9043, name: "endpoint");

Which will produce the error: docker: Error response from daemon: failed to create endpoint peaceful_ellis on network nat: Windows does not support host IP addresses in NAT settings.

Docker inspect shows something like this for the generated container:

JSON:
{
	"Id": "069c43713a55144290df5b87101286b605e2ea54b404eac92afe5cba0d22276f",
	"Created": "2023-11-15T21:43:30.7796535Z",
	"Path": "c:\\windows\\system32\\cmd.exe",
	"Args": [],
	"State": {
		"Status": "created",
		"Running": false,
		"Paused": false,
		"Restarting": false,
		"OOMKilled": false,
		"Dead": false,
		"Pid": 0,
		"ExitCode": 128,
		"Error": "failed to create endpoint peaceful_ellis on network nat: Windows does not support host IP addresses in NAT settings",
		"StartedAt": "0001-01-01T00:00:00Z",
		"FinishedAt": "0001-01-01T00:00:00Z"
	},
	"Image": "sha256:32002da5756a1d4c649a9faf906eb399c2b39d90182614994290ca05c7c42c08",
	"ResolvConfPath": "",
	"HostnamePath": "",
	"HostsPath": "",
	"LogPath": "C:\\ProgramData\\Docker\\containers\\069c43713a55144290df5b87101286b605e2ea54b404eac92afe5cba0d22276f\\069c43713a55144290df5b87101286b605e2ea54b404eac92afe5cba0d22276f-json.log",
	"Name": "/peaceful_ellis",
	"RestartCount": 0,
	"Driver": "windowsfilter",
	"Platform": "windows",
	"MountLabel": "",
	"ProcessLabel": "",
	"AppArmorProfile": "",
	"ExecIDs": null,
	"HostConfig": {
		"Binds": null,
		"ContainerIDFile": "",
		"LogConfig": {
			"Type": "json-file",
			"Config": {}
		},
		"NetworkMode": "default",
		"PortBindings": {
			"9043/tcp": [
				{
					"HostIp": "127.0.0.1",
					"HostPort": ""
				}
			]
		},
		"RestartPolicy": {
			"Name": "no",
			"MaximumRetryCount": 0
		},
		"AutoRemove": false,
		"VolumeDriver": "",
		"VolumesFrom": null,
		"ConsoleSize": [
			0,
			0
		],
		"CapAdd": null,
		"CapDrop": null,
		"CgroupnsMode": "",
		"Dns": [],
		"DnsOptions": [],
		"DnsSearch": [],
		"ExtraHosts": null,
		"GroupAdd": null,
		"IpcMode": "",
		"Cgroup": "",
		"Links": null,
		"OomScoreAdj": 0,
		"PidMode": "",
		"Privileged": false,
		"PublishAllPorts": false,
		"ReadonlyRootfs": false,
		"SecurityOpt": null,
		"UTSMode": "",
		"UsernsMode": "",
		"ShmSize": 0,
		"Isolation": "hyperv",
		"CpuShares": 0,
		"Memory": 0,
		"NanoCpus": 0,
		"CgroupParent": "",
		"BlkioWeight": 0,
		"BlkioWeightDevice": [],
		"BlkioDeviceReadBps": [],
		"BlkioDeviceWriteBps": [],
		"BlkioDeviceReadIOps": [],
		"BlkioDeviceWriteIOps": [],
		"CpuPeriod": 0,
		"CpuQuota": 0,
		"CpuRealtimePeriod": 0,
		"CpuRealtimeRuntime": 0,
		"CpusetCpus": "",
		"CpusetMems": "",
		"Devices": [],
		"DeviceCgroupRules": null,
		"DeviceRequests": null,
		"MemoryReservation": 0,
		"MemorySwap": 0,
		"MemorySwappiness": null,
		"OomKillDisable": false,
		"PidsLimit": null,
		"Ulimits": null,
		"CpuCount": 0,
		"CpuPercent": 0,
		"IOMaximumIOps": 0,
		"IOMaximumBandwidth": 0,
		"MaskedPaths": null,
		"ReadonlyPaths": null
	},
	"GraphDriver": {
		"Data": {
			"dir": "C:\\ProgramData\\Docker\\windowsfilter\\069c43713a55144290df5b87101286b605e2ea54b404eac92afe5cba0d22276f"
		},
		"Name": "windowsfilter"
	},
	"Mounts": [],
	"Config": {
		"Hostname": "069c43713a55",
		"Domainname": "",
		"User": "ContainerUser",
		"AttachStdin": false,
		"AttachStdout": false,
		"AttachStderr": false,
		"ExposedPorts": {
			"9043/tcp": {}
		},
		"Tty": false,
		"OpenStdin": false,
		"StdinOnce": false,
		"Env": null,
		"Cmd": [
			"c:\\windows\\system32\\cmd.exe"
		],
		"Image": "mcr.microsoft.com/windows/nanoserver:ltsc2022",
		"Volumes": null,
		"WorkingDir": "",
		"Entrypoint": null,
		"OnBuild": null,
		"Labels": {}
	},
	"NetworkSettings": {
		"Bridge": "",
		"SandboxID": "",
		"HairpinMode": false,
		"LinkLocalIPv6Address": "",
		"LinkLocalIPv6PrefixLen": 0,
		"Ports": {},
		"SandboxKey": "",
		"SecondaryIPAddresses": null,
		"SecondaryIPv6Addresses": null,
		"EndpointID": "",
		"Gateway": "",
		"GlobalIPv6Address": "",
		"GlobalIPv6PrefixLen": 0,
		"IPAddress": "",
		"IPPrefixLen": 0,
		"IPv6Gateway": "",
		"MacAddress": "",
		"Networks": {
			"nat": {
				"IPAMConfig": null,
				"Links": null,
				"Aliases": null,
				"NetworkID": "",
				"EndpointID": "",
				"Gateway": "",
				"IPAddress": "",
				"IPPrefixLen": 0,
				"IPv6Gateway": "",
				"GlobalIPv6Address": "",
				"GlobalIPv6PrefixLen": 0,
				"MacAddress": "",
				"DriverOpts": null
			}
		}
	}
}

If I instead create the container directly via docker CLI docker run -itd --rm -p 9043 mcr.microsoft.com/windows/nanoserver:ltsc2022, it works just fine and here's the docker inspect that is returned:

JSON:
{
	"Id": "7657d3039fc03a7a6fe9cdfbddbb320c9fe6636c17ae5c019b34b934643b2831",
	"Created": "2023-11-15T21:52:46.7061363Z",
	"Path": "c:\\windows\\system32\\cmd.exe",
	"Args": [],
	"State": {
		"Status": "running",
		"Running": true,
		"Paused": false,
		"Restarting": false,
		"OOMKilled": false,
		"Dead": false,
		"Pid": 1424,
		"ExitCode": 0,
		"Error": "",
		"StartedAt": "2023-11-15T21:52:47.8498881Z",
		"FinishedAt": "0001-01-01T00:00:00Z"
	},
	"Image": "sha256:32002da5756a1d4c649a9faf906eb399c2b39d90182614994290ca05c7c42c08",
	"ResolvConfPath": "",
	"HostnamePath": "",
	"HostsPath": "",
	"LogPath": "C:\\ProgramData\\Docker\\containers\\7657d3039fc03a7a6fe9cdfbddbb320c9fe6636c17ae5c019b34b934643b2831\\7657d3039fc03a7a6fe9cdfbddbb320c9fe6636c17ae5c019b34b934643b2831-json.log",
	"Name": "/fervent_black",
	"RestartCount": 0,
	"Driver": "windowsfilter",
	"Platform": "windows",
	"MountLabel": "",
	"ProcessLabel": "",
	"AppArmorProfile": "",
	"ExecIDs": null,
	"HostConfig": {
		"Binds": null,
		"ContainerIDFile": "",
		"LogConfig": {
			"Type": "json-file",
			"Config": {}
		},
		"NetworkMode": "default",
		"PortBindings": {
			"9043/tcp": [
				{
					"HostIp": "",
					"HostPort": ""
				}
			]
		},
		"RestartPolicy": {
			"Name": "no",
			"MaximumRetryCount": 0
		},
		"AutoRemove": true,
		"VolumeDriver": "",
		"VolumesFrom": null,
		"ConsoleSize": [
			60,
			120
		],
		"CapAdd": null,
		"CapDrop": null,
		"CgroupnsMode": "",
		"Dns": [],
		"DnsOptions": [],
		"DnsSearch": [],
		"ExtraHosts": null,
		"GroupAdd": null,
		"IpcMode": "",
		"Cgroup": "",
		"Links": null,
		"OomScoreAdj": 0,
		"PidMode": "",
		"Privileged": false,
		"PublishAllPorts": false,
		"ReadonlyRootfs": false,
		"SecurityOpt": null,
		"UTSMode": "",
		"UsernsMode": "",
		"ShmSize": 0,
		"Isolation": "hyperv",
		"CpuShares": 0,
		"Memory": 0,
		"NanoCpus": 0,
		"CgroupParent": "",
		"BlkioWeight": 0,
		"BlkioWeightDevice": [],
		"BlkioDeviceReadBps": [],
		"BlkioDeviceWriteBps": [],
		"BlkioDeviceReadIOps": [],
		"BlkioDeviceWriteIOps": [],
		"CpuPeriod": 0,
		"CpuQuota": 0,
		"CpuRealtimePeriod": 0,
		"CpuRealtimeRuntime": 0,
		"CpusetCpus": "",
		"CpusetMems": "",
		"Devices": [],
		"DeviceCgroupRules": null,
		"DeviceRequests": null,
		"MemoryReservation": 0,
		"MemorySwap": 0,
		"MemorySwappiness": null,
		"OomKillDisable": false,
		"PidsLimit": null,
		"Ulimits": null,
		"CpuCount": 0,
		"CpuPercent": 0,
		"IOMaximumIOps": 0,
		"IOMaximumBandwidth": 0,
		"MaskedPaths": null,
		"ReadonlyPaths": null
	},
	"GraphDriver": {
		"Data": {
			"dir": "C:\\ProgramData\\Docker\\windowsfilter\\7657d3039fc03a7a6fe9cdfbddbb320c9fe6636c17ae5c019b34b934643b2831"
		},
		"Name": "windowsfilter"
	},
	"Mounts": [],
	"Config": {
		"Hostname": "7657d3039fc0",
		"Domainname": "",
		"User": "ContainerUser",
		"AttachStdin": false,
		"AttachStdout": false,
		"AttachStderr": false,
		"ExposedPorts": {
			"9043/tcp": {}
		},
		"Tty": true,
		"OpenStdin": true,
		"StdinOnce": false,
		"Env": null,
		"Cmd": [
			"c:\\windows\\system32\\cmd.exe"
		],
		"Image": "mcr.microsoft.com/windows/nanoserver:ltsc2022",
		"Volumes": null,
		"WorkingDir": "",
		"Entrypoint": null,
		"OnBuild": null,
		"Labels": {}
	},
	"NetworkSettings": {
		"Bridge": "",
		"SandboxID": "7657d3039fc03a7a6fe9cdfbddbb320c9fe6636c17ae5c019b34b934643b2831",
		"HairpinMode": false,
		"LinkLocalIPv6Address": "",
		"LinkLocalIPv6PrefixLen": 0,
		"Ports": {
			"9043/tcp": [
				{
					"HostIp": "0.0.0.0",
					"HostPort": "65123"
				}
			]
		},
		"SandboxKey": "7657d3039fc03a7a6fe9cdfbddbb320c9fe6636c17ae5c019b34b934643b2831",
		"SecondaryIPAddresses": null,
		"SecondaryIPv6Addresses": null,
		"EndpointID": "",
		"Gateway": "",
		"GlobalIPv6Address": "",
		"GlobalIPv6PrefixLen": 0,
		"IPAddress": "",
		"IPPrefixLen": 0,
		"IPv6Gateway": "",
		"MacAddress": "",
		"Networks": {
			"nat": {
				"IPAMConfig": null,
				"Links": null,
				"Aliases": null,
				"NetworkID": "02715bd27fc95782e6c2e729c68e6a56d16d875c994c9ab81fa60dceca348bff",
				"EndpointID": "7d05d9513361ee7ef42a9a375cb3dcd7c4af923ab671db7c8444ac9915690265",
				"Gateway": "172.22.48.1",
				"IPAddress": "172.22.58.254",
				"IPPrefixLen": 16,
				"IPv6Gateway": "",
				"GlobalIPv6Address": "",
				"GlobalIPv6PrefixLen": 0,
				"MacAddress": "00:15:5d:4a:e2:55",
				"DriverOpts": null
			}
		}
	}
}

Not sure which part it exactly has a problem with, but there are a few differences in the Networks, Ports, & PortBindings sections.

No documentation officially states whether Aspire specifically supports WCOW, so I would imagine there are other areas that aren't working too well.

gerneio avatar Nov 15 '23 22:11 gerneio

@mitchdenny is this app model? (btw we should have the labeler working soon, meantime we have to set area manually)

danmoseley avatar Nov 16 '23 03:11 danmoseley

Tooling for now.

mitchdenny avatar Nov 17 '23 03:11 mitchdenny

Windows containers are out of scope for at least the first version.

davidfowl avatar Jan 27 '24 20:01 davidfowl

Any roadmap / plans to support this in the future?

StefH avatar May 23 '24 18:05 StefH

It's currently not a priority no.

davidfowl avatar May 24 '24 00:05 davidfowl

And therefore this will keep me from being able to utilize aspire effectively, bummer. Unfortunately windows is a big part of our stack still.

gerneio avatar Feb 14 '25 20:02 gerneio