- [Instructor] Deleting images or removing images
as Docker calls it, is easy to do
if we do a docker images.
And if we wanted to remove,
we could do a rmi, which is the deprecated command
or what you should use, is docker image rm,
and we could remove this image named dog.
Optionally you could add latest,
but that is the default tag,
so that really doesn't need to be on there.
So we untagged that image that had multiple tags.
In this case the image is this 3f8.
Notice how it also has a tag of nginx,
another tag here of daviddavisx/nginx.
Another tag here of daviddavistx/webserver.
So that same image is used multiple times.
What if we wanted to remove all of these?
We can actually do a docker image rm
and we could specify every one of these in sequence.
And there we go.
It looks like all the images were removed
except perhaps that last image.
We got an error on that.
No such image.
Let's do a docker images again,
and it looks like that 3f8 image is still there.
So how do we get rid of that?
Let's do a docker image rm.
And actually we can do a 3f8.
And while we did specify the image ID,
which normally would allow us to get rid of that image,
it tells us we are unable to delete it.
It must be forced because it's being used
by a stopped container.
So if we do a clear.
Let's do a docker image rm on that image,
but this time we'll use --force
to force the removal of that image.
And there we go.
We successfully deleted the source image,
the original image, not just a tag of the image,
but the actual image is gone.
If we do docker images, we can see
that image that started with 3f8 is
no longer in this list.
So that image was successfully removed.
So that's how easy it is to delete images
on a local Docker host.
But what if you need to delete an image in a registry?
Well, there are some scripts out there
that I've seen, to help you do that
from the command line.
But typically, I would just go to the GUI.
Whether it's Docker Hub out on the web,
or whether it's a private registry
like Docker Trusted Registry.
Let's give it a try.
Here in Docker Hub, if we scroll down
and for example select daviddavis/nginx,
and go into Settings,
here I can click to delete this repository.
You have to do a verification, and click Delete.
And then back here on the dashboard,
as you can see, that repository is gone
along with the image that was uploaded
to that repository.
So that's an easy, quick way to remove an image
from a registry.
But what if it's in Docker Trusted Registry?
Here in Docker Trusted Registry,
if we go into, for example, this repository,
david/web, and view details,
you can see we do have an image in here.
I can select that image and I can click simply Delete.
It says the tag httpd will be deleted.
This cannot be undone.
And there we go.
The image is gone.
So that's how easy it is to delete images
from a registry whether it's Docker Hub
or Docker Trusted Registry.