- [Instructor] Tagging images is a very important concept
when it comes to Docker administration.
So, if we do docker space tag,
you can see that the docker tag command
requires exactly two arguments:
source image colon tag and target image colon tag.
And notice that the tags are actually optional.
So I could just take a source image, and I could
rename it or tag it with a new target image name.
I know it can be a little bit confusing,
but let me show you an example,
and maybe it will be more clear.
So if we do docker images here,
let's take one image, for example, nginx.
We clear the screen.
Let's do a docker tag.
Ngnix.
And keep in mind these tags are just arbitrary words,
so I could call this nginx image bunny.
Right, so now we have a new image named bunny.
And it's listed right here.
Bunny colon latest.
So, we've got a bunny image.
Now we could take that image,
and we could tag bunny with dog.
So now if we a docker images,
again, we have nginx.
We have dog and bunny.
And really these all point back to the exact same image id.
So we've just created these new image names
that point back to the same image id,
the same original image.
And we could remove these tags if we wanted to,
but the same original image,
the same source image, will remain.
Also notice that the default tag for all these new
image tags that we created is latest.
So if you don't specify anything, then latest will become
the tag for that image that you create.
For example if I do a docker image remove on bunny,
notice it was untagged.
We'll do a docker images, and indeed,
the image named bunny is gone.
So that's how easy it is to put some basic tags on an image.
Now if you're going to be pushing images up
to a public registry, then you're going
to need to give the registry name.
For example daviddavistx was added here in front of the name
of the web server image.
On the other hand, if an image going to be pushed up
to a private repository, it might like more like this,
where I have an IP address or a hostname here,
colon typically some port number like colon 5000
to push it up to a private registry.
So that's how you tag images in Docker.