- [Instructor] A Docker repository is a collection
of related Docker images with the same name
but different tags.
A registry, on the other hand,
is a place where you store your images.
A registry can be public, it can be private,
and it can have multiple repositories.
The most common and default registry for Docker
is Docker's own public registry, Docker Hub.
As part of a new Docker installation
it's common to set up a repository
and link it to Docker Hub.
Let's create a local repository
and push it up to Docker Hub.
The first thing we need to do is to log in to Docker Hub.
This is done with the Docker login command.
Docker login first prompts you for your
Docker Hub user ID or username,
as well as your password.
Let's go over to hub.docker.com
and I'll show you how to create your Docker ID.
Creating a Docker Hub ID is free.
And you can do it by entering a Docker ID that you choose,
your email address, and password.
In our case, I've already created a Docker ID.
So I'm going to log in.
And here you can see the repositories
that I've created in Docker Hub.
So let's go back to Linux
and we'll enter our Docker Hub username
and password.
And now we've logged in successfully to Docker Hub
from this Docker Client.
And I should point out, what we're doing here
while we happen to be in Ubuntu Linux,
it works with any addition of Docker,
whether it's community or enterprise
and it works on all Docker platforms.
So let's go ahead and pull down an image.
We're going to pull down a small alpine,
oops misspelled that one.
Let's try it again, docker pull space alpine.
Alpine is a tiny Linux image,
and if we do a clear here on the screen,
let's look at the Docker images that we have.
You can see we now have a Docker Linux image
called alpine, and it has a tag of latest.
So it's the latest edition of alpine Linux.
So now what we're going to do is to give this
alpine Linux addition a few different tags.
So we're going to use the Docker tag command,
and we're going to give it the image ID,
and you don't actually have to give the entire iamge ID.
You can just give it the first three unique letters,
so you can see the 3fd that I'm using here
was actually pulled from the image ID above.
So it's just a quick way to reference the images
that are in your local repository.
So I've given it an image ID.
We're going to tag it with my Docker ID,
which is required, so that this image
is going to be pushed up into your Docker repository
under your Docker ID.
Then we'll enter the name of the image here,
and then let's give it a tag.
In this case we'll just call it linkedin1.
So we tagged that image once with linkedin1.
Let's go ahead and tag it again with linkedin2
and linkedin3.
So we tagged this image three different times
and already had one tag,
and if we do a Docker images now,
you can see we have one image in the repository,
because all the image IDs are the same.
But we have four different tags associated with that image.
Three of them, however, are configured with the Docker ID
and the name of the repository up on Docker Hub.
So now let's push this repository of images
up to Docker Hub.
To do that we'll do a Docker push.
We'll enter our Docker ID,
and then the name of the repository.
It tells us that the layer already exists,
and that means that the image was actually already up there,
but what didn't exist are the three different tags
that we just assigned to that image.
So now let's go over to Docker Hub.
We'll refresh our browser.
Let's go into the daviddavistx/alpine repository.
Let's go into tags,
and here you can see the new tags for that image
that we've pushed up to Docker Hub.
We also have a number of other tags
in the repository as well for the same image.
In this case, they're test, prod, and dev.
All just examples of how you can tag the same image
with multiple tags.
So now let's go back to our Docker Client.
Clear the screen and I'll do a Docker images again.
And now let's delete this image
that we have locally.
I'm going to do a Docker image rm
and give it the first three letters of the image ID.
It tells us that that image is referenced
by multiple repositories,
so if we want to delete it we actually have to do a -f
to force deletion.
We can see we've deleted the image.
Let's clear our screen.
Let's make sure that the image is actually gone.
It is.
And now let's pull back down using docker pull,
the images that we pushed up to Docker Hub.
Let's do a docker images,
and after we deleted that image or removed that image,
we're now able to pull it back down
from Docker Hub.
So this is just an example of creating a local repository,
connecting to Docker Hub a public registry,
and being able to push and pull images back and forth.