How to remove all Docker containers

Remove containers based on status:

docker rm -v $(docker ps --filter status=exited -q)

Note:

  • The "-v" option that will delete any volumes associated with the containers.

To clean out all containers on my development machine:

docker rm -v -f $(docker ps -qa)

Note:

  • The "-f" option will force the removal of a running container

For Windows:

C:\> for /F %i in ('docker ps -qa') do docker rm %i

docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)

For Windows (PowerShell):

docker rm -f $(docker ps -a -q)

Tags:

Linux

Docker