[No Audio]
So, in this demo, we will learn different ways of
removing the containers. Let's list out all of the
our containers and yes, there are quite a lot of them.
In fact, many of them are not even that
significant at the moment and should be removed.
First, we have the basic rm command, followed by a
containers name. Here, we have preferred a stopped
container cont_from.
Once it is removed, it will disappear from the list.
Then we have the same rm command, but instead of providing
name, we have provided the container ids of the
stopped containers, and the result is the same,
they disappear from the list after being removed.
The case will be a bit different with the running
containers, just to make sure that we are not
making any mistakes while deleting a running
container, it asks us to provide the force
deletion flag. I would say it is a kind gesture,
since it avoids potential unforced errors.
As we add the force flag, nothing can stop us from
removing it. If we want to be kind to containers
and want to kill them properly, we can send the
SIGTERM signal using docker container kill command.
But as you can see, we still have quite a
few containers running and we don't need the
stopped ones for the most part.
To remove the stopped containers we have a command called
docker container prune.
It is a short and sweet command
and doesn't require any names or ids.
It will simply kill all of the dangling containers and
free up whatever resources it can.
We had 3 of such containers which got removed and we got 1.8
megabytes of free space.
Finally, our list of containers
only contain the live ones.
In next module, we'll go deeper into networking