Docker cleanup
Throughout this chapter, we have created a number of containers and images. This is, however, only a small part of what you will see in real-life scenarios. Even when containers are not running, they need to be stored on the Docker host. This can quickly result in exceeding the storage space and stopping the machine. How can we approach this concern?
Cleaning up containers
First, let's look at the containers that are stored on our machine. Here are the steps we need to follow:
- To print all the containers (irrespective of their state), we can use the
docker ps -a
command, as follows:$ docker ps -a CONTAINER ID IMAGE COMMAND STATUS PORTS NAMES 95c2d6c4424e tomcat "catalina.sh run" Up 5 minutes 8080/tcp tomcat a9e0df194f1f ubuntu:20.04 "/bin/bash" Exited jolly_archimedes...