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 the containers are not running at the moment, 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. To print all the containers (no matter of their state), we can use the docker ps -a
command:
$ docker ps -a CONTAINER ID IMAGE COMMAND STATUS PORTS NAMES 95c2d6c4424e tomcat "catalina.sh run" Up 5 minutes 8080/tcp tomcat a9e0df194f1f ubuntu:16.04 "/bin/bash" Exited jolly_archimedes 01bf73826624 ubuntu:16.04 "/bin/bash" Exited suspicious_feynman 078e9d12a1c8 tomcat "catalina.sh run" Up 14 minutes 0.0.0.0:32772->8080/tcp nauseous_fermi 0835c95538ae tomcat "catalina.sh run" Created distracted_heyrovsky...