Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all Docker containers

Tags:

linux

docker

I want to remove all of my docker containers at once. I tried to use $ docker rm [container_id] to do so, but it removed only one container, not all.

Is there any way to remove all docker containers using one single line of code?

like image 348
Erfan Tahriri Avatar asked Feb 06 '16 11:02

Erfan Tahriri


Video Answer


1 Answers

As from Docker 1.13.0 --- Docker API 1.25:

docker container prune

Output:

WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
df226cc24539833a1c88f46bfa382ebe2e89c21805288f5e6bfc37cb7f662505
993bd58faaa22cb5dbc263eca33c8d1a241bd0a1f73b082e23e3a249fe1dfc0d
...

Total reclaimed space: 13.88MB

See more on docker container prune

There is docker versioning matrix for better understanding docker versions (current is Docker 17.12 --- Docker API 1.35)

like image 63
David Avatar answered Sep 28 '22 07:09

David