How can I stop all docker containers running on Windows?
docker stop
is for 1 container only.
Any command/script to make it stop all containers?
How can I stop all docker containers running on Windows?
docker stop
is for 1 container only.
Any command/script to make it stop all containers?
You could create a batch (.bat) file with these commands in it:
@ECHO OFF
FOR /f "tokens=*" %%i IN ('docker ps -q') DO docker stop %%i
If you want to run this command directly in the console, replace %%i
with %i
, like:
FOR /f "tokens=*" %i IN ('docker ps -q') DO docker stop %i
In Git Bash or Bash for Windows you could run:
docker stop $(docker ps -q)
For those who are interested this can be accomplished in Powershell using
docker ps -q | % { docker stop $_ }