Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep WIndows Container running?

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?

like image 914
user7610 Avatar asked Dec 18 '22 17:12

user7610


2 Answers

Use ping -t localhost will do it

like image 71
Gregory Suvalian Avatar answered Jan 31 '23 04:01

Gregory Suvalian


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
like image 44
FireEmerald Avatar answered Jan 31 '23 04:01

FireEmerald