[No Audio]
First of all, we have docker search command.
It is used to search images from Docker Hub.
Just to clarify, you don't need to have a Docker Hub account
to search repos from your host or even
pulling them. It is just a requirement to use the
web interface of Docker Hub or for pushing
repositories on it.
As for the syntax of this command,
the phrase docker search is followed by
the name of the image, and optional version number
after colon. Let's execute this command.
Here, we get a list of Python images sorted by the number of stars.
Of course, many of them are frameworks
built on top of Python, since Python would be one
of the keywords. There are description of images
to provide more brief insight and a check of
whether the image is official or not.
Here, the first image has the most stars and it is also the
official image. Next, we have quite a special case.
'docker search registry' command gives
official image of Docker Registry from Docker Hub.
If we don't want to get such a long list of repositories,
we can also put filters on our search.
Here, we have put filter 'is-official=true',
which will only show us the official images.
There we go, we only got one image.
Sweet, right? For those who like their
results neat and tidy, Docker also lets you format
the results of the search. Here, the format is
mentioned in double inverted commas and it starts
with the keyword table, which means we want a
tabular format. Then, we have entered the desired
fields that we want. The fields are mentioned in
double curly braces, and they are separated by
'\t', which stands for tab or space character.
You might have guessed by now that this
will create three columns one of each field.
Now, that the predictions and wish lists are done,
let's run the command. There we go, our crowded
little table is here and it is showing the same
repositories as before, just in visually different format.
Also notice that we only have three fields
that we had mentioned in the command and rest of
the fields are skipped.
[No Audio]
Moving on from docker search,
we have docker image command. It is a
shorter version of docker images 'ls' command and
both of them do exactly the same thing, which is
list out the images on your host. As you can see,
these are the images that we built during our
previous section. On the other hand, if we want to
list out versions or instances of particular type
of image, we can mention the image name followed
by docker image command. Let's try and list all our Ubuntu images.
Here we can also see the size
of the image, which denotes the size they
currently occupy on the storage of host machine.
Of course, specifying the version number preceded
by a colon narrows down the list just to one entry.
Furthermore, if we want to see the full
parts of truncated data, like image id, we can use
--no -trunc flag as well,
but be cautious while using it since it can make the
results messy, really messy.
[No Audio]
Then we have docker pull, it pulls the specified
image from Docker Hub to our Docker host. Here, we
have provided nginx with :latest tag.
So whichever image will have the latest tag on Docker
Hub's nginx repository, will be pulled.
As you can see, it has downloaded a newer version of
nginx which is latest.
Instead of latest, if we use
'nginx:alpine', Docker Hub will provide an
image with alpine tag. Now, if we grab a list of
available nginx images on our host, we get two of them.
First is the alpine one, which we just
pulled and second is the latest version.
As you can see, both of them vary majorly in terms of size.
Alpine is like minimal nginx image, which is
smaller in terms of size, since alpine as the base OS
itself is smaller. Finally, if we want all
variants of nginx images, say for testing purpose,
we can hit the command with --all tags flag
and we will receive the missing images
from the repository. Once we list the nginx images now,
it is clearly visible that these are
different versions with different sizes.
[No Audio]
We are back to our Docker Hub dashboard, let's click on
Create Repository option so we can make a repo and
push images to it.
On the left pane, Docker is
generous enough to list out the steps to create a repo.
First of all, we are supposed to provide a
namespace for our repositories, so that we don't
have to make the name unique across the globe.
Generally, namespace is same as the username.
Now, let's name our repository.
We are naming it 'repo-nginx'. You can name it anything you like.
[No Audio]
Next step is the description of this repo.
Here. As you can see, we have given a short and
sweet description about this repo.
If you want to describe your repo in much more detail, you can
jump to the full description section of this repo.
And in the final step, we can set the visibility
permission for our repository.
Docker offers one free private repo
and unlimited public repo with
free Docker Hub account.
So do your choices wisely.
We don't need private repos for now, so we
will select the public visibility for this repo.
Now let's create the repo by pressing Create
button at the end of the page.
[No Audio]
We have successfully created our repo-nginx.
As we can see, that there are some tabs above the short
description of the repo, first one is Repo Info tab,
it displays the basic information about our
repo-nginx such as its visibility, which is
public, and short description about it.
Second one is tags,
you can add multiple images under a
single repo separated by different tags.
If you do not specify any tag for the image,
it will by default take latest tag.
Third one is collaborators, it consists of a user or a list of
user whom the owner of the private repo wants to
grant the read, write, or admin access.
Next and the fourth one is Webhooks, Webhook is a HTTP
callback POST request. It can be used to notify
user, services or other applications about the
newly pushed image to the repo.
Last one is the settings of the repo, here, user can change the
visibility permission of the repo and can also
delete the repo from user's Docker Hub account permanently.
Now, as you can see, you can pull the
images available under the repo-nginx repository.
By using this specific docker pull command,
docker pull ceruleancanvas/repo-nginx
and store them on your machines.
Since this is your first ever repository created on Docker Hub,
let's self indulge ourselves by giving it a star.
[No Audio]
Starring repo is a way to show that you liked the
repository and you can remember it for your future references.
Now let's switch back to the terminal.
Before pushing an image to Docker Registry,
we need to log in again to Docker Hub using
docker login command interactively.
[No Audio]
Here, we have been asked to enter our Docker Hub
login credentials, we will enter our username
which is ceruleancanvas and its password.
We have successfully logged in our account with a warning
which says that our Docker Hub password is stored
unencrypted in config.json file on our machine for future references.
We are okay with it for now,
so we will ignore the warning and proceed to the next step.
Now we will tag a local image nginx:latest
into a new image.
We will specify where we want to push this image,
we can write the hostname on which the registry is hosting, which
is ceruleancanvas for us.
Now, we will mention the registry name in which we want to push
the image that is repo-nginx.
You want to give your own custom tag to the image such as
cc-nginx for this example.
Or, if you don't mention any tag for the image,
it will take latest by default.
This two stage format is mandatory to
push an image to a public repository.
Now let's check out our newly tagged image by listing all
images on our machine. There you are, we have original
nginx latest image and newly tagged
'ceruleancanvas/repo-nginx:cc-nginx image'.
But did you notice something,
these two images have the same image ID.
It is because docker tag command has created an alias for your
image as its new image name. So that the original
image will be untouched and all of its changes can
be performed to the new alias image.
Now, let's push the ceruleancanvas/repo-nginx:cc-nginx
to all repo-nginx, using docker push command.
We have already specified the path
for the destination location in image name.
As we can see, Docker is pushing each layer of the
original latest image at this end.
On the other hand, Docker daemon will stack all of these layers
sequentially and create a new image with the tag
cc-nginx in the repo-nginx.
At the end of
At the end of the process, we got our
new image digest identifier of the push image.
Now let's switch back to Docker Hub account
to verify that our repo has been successfully pushed,
we will navigate to the repo-nginx repository,
go to tags and we have
successfully pushed the image. Image tag, size, and
updated name are mentioned here.
In next lecture, we will dig deeper
into the image by inspecting it and looking at its history.