- [Instructor] Downloading Docker images
is very easy to do, and, dare I say, even fun.
You can download new containers that do things
that you've never seen before.
However, the downside is that you may
run out of disc storage capacity for all the images
that you download from the Internet.
Thankfully, Docker makes it easy to prune,
as they call it, the unused images.
By default, you can use the command Docker Image Prune
to clean up what they call dangling images.
A dangling image is an image that's not tagged
and not referenced by any specific container.
You can use the command Docker Image Prune
to prune the dangling images.
You can also use a minus A flag to remove all images
that are not used by existing containers.
You can even use a minus F to force
the removal of the images,
or the pruning of the images,
and not actually prompt you with the warning message.
Finally, you can even do some filtering commands here
to, for example, find container images that were
created more than 24 hours ago.
You can also prune containers that aren't running
with the Docker Container Prune Command.
You can prune Docker volumes as well as Docker networks,
and even, yes, you can prune everything.
Docker System Prune will prune all stopped containers,
all networks that are not used by at least one container,
all dangling images, and all build caches.
This can save you a lot of disc space,
but you also have to be very careful
that you don't accidentally get rid of something
that you really need.
Now let's go over to the command line inside Docker
and I'll show you how to clean up unused Docker images
using the Docker Image Prune command.
Here in Docker, if we use Docker image space prune,
this tells us that it will remove all dangling images.
Are you sure you want to continue?
I'll say yes.
And then, look at that.
We reclaimed 194 megabytes simply by deleting
unused or dangling container images.
We could also use the Docker system prune command,
which tells us it will remove all stopped containers,
all networks, all danging images, and all build caches.
I'll tell you, though, however,
I have many containers out there that are stopped
and I would really like to keep.
So, in this case, we'll say no.
But that's a very important, very useful
cleanup command when it comes to maximizing
the disc capacity, or disc space, on a Docker host.
So I encourage you to keep the Docker Image Prune
and Docker System Prune commands in mind
when it comes to maximizing disc capacity.