Docker

How to delete unused docker objects

In this article, introduce how to delete unused docker objects.

Let’s get straight to the point.

What is docker objects

In docker objects, there are image and container, network, volume, etc.

Representative docker objects list
  • image: Template image file for Operating environment of docker container
  • container: Operating environment of application
  • network: Providing complete isolation for docker container
  • volume: Where to store data of docker container permanently

How to delete unused docker objects

In docker, There is option “prune” that bulk deletion unused docker objects.

But there is a points to note.

It’s you can’t restore docker objects that was deleted by using option “prune”.

Please note that point, use the following command.

How to bulk delete

docker system prune -a

If you use this command, you can bulk delete unused docker objects such as image, container, network, volume, etc.

How to bulk delete only container

docker container prune

If you use this command, you can bulk delete unused container.

But the above command display confirmation statement, so if you want to skip, execute the following command.

docker container prune -f

How to bulk delete only image

docker image prune
docker image prune -f

Docker image is the same as container too.

How to bulk delete only network

docker network prune
docker network prune -f

Docker network is the same as container and image too.

How to bulk delete only volume

docker volume prune
docker volume prune -f

Docker volume is the same as container and image, network too.