How to Remove Old Docker Containers?

Better Stack Team
Updated on August 1, 2022

You may have found docker rm command to remove a docker container. However, this works only for a single container and it would be very painful to run this command for every non-running docker container. Luckily, since Docker 1.13 there is a more elegant solution.

How to remove old Docker containers?

To remove all stopped containers, run the following command:

docker container prune

There is also system prune, which will clean up all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes, in one command.

docker system prune
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →