How to Clean Up Docker

  • Post last modified:October 20, 2023
  • Post category:Linux
  • Post comments:2 Comments
  • Reading time:2 mins read

Docker creates many layers of images as you build and run containers, which can result in large amounts of unused data. Docker provides a simple solution for cleaning up this unused data: docker system prune.


The docker system prune command removes unused data, including images, containers, networks, and volumes. This is useful for freeing up disk space and keeping your Docker environment running smoothly.

One of the most commonly used options with docker system prune is the -a or --all flag. This option removes all unused images, not just dangling ones. Dangling images are images that are not associated with a container. Using the -a flag will remove all images that are not in use by a container.

To run docker system prune, open a terminal and enter the command:

sudo docker system prune -a -f

Be careful when using this option, as it will delete all unused data without asking for confirmation.

You can also use docker system prune with additional options to specify exactly what you want to remove. For example, you can use the --volumes flag to remove unused volumes.


To see all available options for docker system prune, enter the following command:

docker system prune --help

Share your thoughts and questions in the comments below thank you.

This Post Has 2 Comments

  1. Armaan

    you save my server disk space thanks.

  2. Grimy


Leave a Reply