This is a Docker on Windows Server 2022 (21H2) Vagrant environment for playing with Windows containers.
For Windows Server 2019 (1809) see the rgl/docker-windows-2019-vagrant repository.
Install the Base Windows Server 2022 Box.
Then launch the environment:
vagrant up --no-destroy-on-error --provider=libvirt # or --provider=virtualbox
At the end of the provision the examples are run.
The Docker Engine API endpoint is available at http://10.0.0.3:2375.
Windows containers cannot be gracefully shutdown because they are forcefully terminated after a while. Check the moby issue 25982 for progress.
The next table describes whether a docker stop --time 600 <container>
will graceful shutdown a container that is running a console, gui, or service app.
base image | app | behavior |
---|---|---|
mcr.microsoft.com/windows/nanoserver:ltsc2022 | console | receives the CTRL_SHUTDOWN_EVENT notification but is killed after about 5 seconds |
mcr.microsoft.com/windows/servercore:ltsc2022 | console | receives the CTRL_SHUTDOWN_EVENT notification but is killed after about 5 seconds |
mcr.microsoft.com/windows/server:ltsc2022 | console | receives the CTRL_SHUTDOWN_EVENT notification but is killed after about 5 seconds |
mcr.microsoft.com/windows/nanoserver:ltsc2022 | service | receives the SERVICE_CONTROL_PRESHUTDOWN notification but is killed after about 15 seconds |
mcr.microsoft.com/windows/servercore:ltsc2022 | service | receives the SERVICE_CONTROL_PRESHUTDOWN notification but is killed after about 15 seconds |
mcr.microsoft.com/windows/server:ltsc2022 | service | receives the SERVICE_CONTROL_PRESHUTDOWN notification but is killed after about 15 seconds |
mcr.microsoft.com/windows/nanoserver:ltsc2022 | gui | fails to run because there is no GUI support libraries in the base image |
mcr.microsoft.com/windows/servercore:ltsc2022 | gui | does not receive the shutdown messages WM_QUERYENDSESSION or WM_CLOSE |
mcr.microsoft.com/windows/server:ltsc2022 | gui | does not receive the shutdown messages WM_QUERYENDSESSION or WM_CLOSE |
NG setting WaitToKillServiceTimeout
(e.g. Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control -Name WaitToKillServiceTimeout -Value '450000'
) does not have any effect on extending the kill service timeout.
NB setting WaitToKillAppTimeout
(e.g. New-ItemProperty -Force -Path 'HKU:\.DEFAULT\Control Panel\Desktop' -Name WaitToKillAppTimeout -Value '450000' -PropertyType String
) does not have any effect on extending the kill application timeout.
You can launch these example containers from host as:
vagrant execute --sudo -c '/vagrant/ps.ps1 examples/graceful-terminating-console-application/run.ps1'
vagrant execute --sudo -c '/vagrant/ps.ps1 examples/graceful-terminating-windows-service/run.ps1'
vagrant execute --sudo -c '/vagrant/ps.ps1 examples/graceful-terminating-gui-application/run.ps1'
This environment builds and uses the following images:
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox-info latest 6560bd5e0195 26 minutes ago 294MB
go-info latest a6811b530260 26 minutes ago 295MB
csharp-info latest 5bafc497b060 27 minutes ago 368MB
powershell-info latest 122de1e0f002 30 minutes ago 5.44GB
batch-info latest bf65ff51c534 31 minutes ago 293MB
busybox latest a79f85817544 31 minutes ago 293MB
golang 1.23.5 6772f8637074 31 minutes ago 652MB
mcr.microsoft.com/powershell 7.4-windowsservercore-ltsc2022 bfe3f67c1ad2 2 months ago 5.42GB
mcr.microsoft.com/dotnet/sdk 8.0-nanoserver-ltsc2022 2cc9a44e800c 9 days ago 1.26GB
mcr.microsoft.com/dotnet/runtime 8.0-nanoserver-ltsc2022 784740758bbe 9 days ago 368MB
mcr.microsoft.com/windows/server ltsc2022 16f97fcf4440 11 days ago 10.5GB
mcr.microsoft.com/windows/servercore ltsc2022 7f1b8b9185ba 11 days ago 5.16GB
mcr.microsoft.com/windows/nanoserver ltsc2022 c6f91e0896e4 11 days ago 293MB
- Restart the docker daemon in debug mode and watch the logs:
- set
"debug": true
inside the$env:ProgramData\docker\config\daemon.json
file - restart docker with
Restart-Service docker
- watch the logs with
Get-EventLog -LogName Application -Source docker -Newest 50
- set
- For more information see the Microsoft Troubleshooting guide and the CleanupContainerHostNetworking page.