How To Use Docker To Stop And Remove All Windows Server Containers

I’ve been playing around with Containers on Windows Server 2016 GA. I can’t say I’m enthralled with Docker being the default interface for Containers now, but I understand Microsoft’s motivation.

I needed a way to quickly:

  • Stop all running containers on a host
  • Remove all containers from the host

If this was PowerShell, it would have been easy. But dragging open source onto Windows causes issues …. they do things inconsistently and all the docs are for Linux. Grep! Really!?!?

Eventually I found 1 variation of a solution that worked. The first line stops all running containers:

docker stop (docker ps –qa)

The second line removes all running containers:

docker rm (docker ps –qa)

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.