Created
December 20, 2020 06:44
-
-
Save vijaysharmay/a6fdef60254da5acde7d0e191f5567df to your computer and use it in GitHub Desktop.
BAT file for stopping & removing all containers on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ECHO OFF | |
| FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker stop %%i | |
| FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i |
Author
Author
You can also use the below command to remove all dangling images:
FOR /f "tokens=*" %%i IN ('docker images -f "dangling=true" -q') DO docker rmi %%i
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For running this in cmd.exe (Windows CMD) replace the %%i with %i
For example, you can run the below command to stop all running containers:
FOR /f "tokens=*" %i IN ('docker ps -aq') DO docker stop %iand you can run this command to remove all containers
FOR /f "tokens=*" %i IN ('docker ps -aq') DO docker rm %i