Reputation: 28919
I need to keep my Windows Container up so I can run further commands on it using docker exec
.
On Linux, I'd start it to run either sleep infinity
, or tail -f /dev/null
. Alternatively, I could borrow pause.c
from Kubernetes.
What does this look like on Windows?
Upvotes: 9
Views: 11119
Reputation: 28919
Kubernetes on Windows used to use ping
cmd /c ping -t localhost
This would print lots of unnecessary output, so a good improvement should be
cmd /c ping -t localhost > NUL
What Kubernetes does now is to run a custom pauseloop.exe binary.
In late 2022, the current home for wincat/pauseloop is https://github.com/kubernetes/kubernetes/tree/master/build%2Fpause%2Fwindows%2Fwincat. The move was implemented in https://github.com/kubernetes-sigs/sig-windows-tools/pull/270.
Upvotes: 4
Reputation: 1390
A full run command would be:
docker run -d --name YourContainer mcr.microsoft.com/windows/nanoserver:1809 ping -t localhost
Note: Make sure 1809 is equal with your own windows version from [WIN]
+[R]
-> winver
.
You should then be able to step into the running container instance with the name YourContainer
:
docker exec -it YourContainer cmd
Upvotes: 4