How to sterilize your Docker Host

Here is a pretty handy set of commands that will clean out your Docker host of all containers and images. It’s useful when resetting a demo environment to start fresh.

Step 1: Stop all docker images

docker stop $(docker ps -aq)

Step 2: Remove all containers

docker rm $(docker ps -aq)

Step 3: Remove all images

docker rmi $(docker images -q)

Now running “docker images” command and you will see no images there:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s