Skip to content

Instantly share code, notes, and snippets.

@vijaysharmay
Created December 20, 2020 06:44
Show Gist options
  • Select an option

  • Save vijaysharmay/a6fdef60254da5acde7d0e191f5567df to your computer and use it in GitHub Desktop.

Select an option

Save vijaysharmay/a6fdef60254da5acde7d0e191f5567df to your computer and use it in GitHub Desktop.
BAT file for stopping & removing all containers on Windows
@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
@vijaysharmay
Copy link
Author

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 %i

and you can run this command to remove all containers

FOR /f "tokens=*" %i IN ('docker ps -aq') DO docker rm %i

@vijaysharmay
Copy link
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