1 00:00:00,001 --> 00:00:03,967 [No Audio] 2 00:00:03,967 --> 00:00:06,934 First of all, we have docker search command. 3 00:00:06,934 --> 00:00:09,634 It is used to search images from Docker Hub. 4 00:00:09,634 --> 00:00:14,034 Just to clarify, you don't need to have a Docker Hub account 5 00:00:14,034 --> 00:00:16,601 to search repos from your host or even 6 00:00:16,601 --> 00:00:19,634 pulling them. It is just a requirement to use the 7 00:00:19,634 --> 00:00:22,467 web interface of Docker Hub or for pushing 8 00:00:22,467 --> 00:00:24,134 repositories on it. 9 00:00:24,601 --> 00:00:26,834 As for the syntax of this command, 10 00:00:27,267 --> 00:00:30,034 the phrase docker search is followed by 11 00:00:30,034 --> 00:00:33,366 the name of the image, and optional version number 12 00:00:33,433 --> 00:00:36,901 after colon. Let's execute this command. 13 00:00:37,867 --> 00:00:42,834 Here, we get a list of Python images sorted by the number of stars. 14 00:00:43,434 --> 00:00:45,967 Of course, many of them are frameworks 15 00:00:45,967 --> 00:00:49,134 built on top of Python, since Python would be one 16 00:00:49,134 --> 00:00:52,167 of the keywords. There are description of images 17 00:00:52,167 --> 00:00:55,267 to provide more brief insight and a check of 18 00:00:55,267 --> 00:00:57,767 whether the image is official or not. 19 00:00:58,834 --> 00:01:03,934 Here, the first image has the most stars and it is also the 20 00:01:03,934 --> 00:01:07,901 official image. Next, we have quite a special case. 21 00:01:08,634 --> 00:01:11,901 'docker search registry' command gives 22 00:01:11,901 --> 00:01:15,401 official image of Docker Registry from Docker Hub. 23 00:01:15,401 --> 00:01:18,667 If we don't want to get such a long list of repositories, 24 00:01:18,667 --> 00:01:21,667 we can also put filters on our search. 25 00:01:21,901 --> 00:01:26,867 Here, we have put filter 'is-official=true', 26 00:01:27,467 --> 00:01:30,434 which will only show us the official images. 27 00:01:31,134 --> 00:01:34,801 There we go, we only got one image. 28 00:01:34,801 --> 00:01:37,901 Sweet, right? For those who like their 29 00:01:37,901 --> 00:01:41,667 results neat and tidy, Docker also lets you format 30 00:01:41,667 --> 00:01:45,134 the results of the search. Here, the format is 31 00:01:45,134 --> 00:01:49,201 mentioned in double inverted commas and it starts 32 00:01:49,201 --> 00:01:52,367 with the keyword table, which means we want a 33 00:01:52,367 --> 00:01:55,867 tabular format. Then, we have entered the desired 34 00:01:55,867 --> 00:01:59,567 fields that we want. The fields are mentioned in 35 00:01:59,567 --> 00:02:02,667 double curly braces, and they are separated by 36 00:02:02,667 --> 00:02:07,601 '\t', which stands for tab or space character. 37 00:02:08,866 --> 00:02:11,334 You might have guessed by now that this 38 00:02:11,334 --> 00:02:14,001 will create three columns one of each field. 39 00:02:14,167 --> 00:02:17,234 Now, that the predictions and wish lists are done, 40 00:02:17,434 --> 00:02:21,334 let's run the command. There we go, our crowded 41 00:02:21,334 --> 00:02:24,201 little table is here and it is showing the same 42 00:02:24,201 --> 00:02:29,034 repositories as before, just in visually different format. 43 00:02:29,034 --> 00:02:31,967 Also notice that we only have three fields 44 00:02:31,967 --> 00:02:34,767 that we had mentioned in the command and rest of 45 00:02:34,767 --> 00:02:36,167 the fields are skipped. 46 00:02:36,167 --> 00:02:37,634 [No Audio] 47 00:02:37,634 --> 00:02:39,434 Moving on from docker search, 48 00:02:39,434 --> 00:02:42,234 we have docker image command. It is a 49 00:02:42,234 --> 00:02:46,001 shorter version of docker images 'ls' command and 50 00:02:46,001 --> 00:02:49,734 both of them do exactly the same thing, which is 51 00:02:49,967 --> 00:02:53,967 list out the images on your host. As you can see, 52 00:02:53,967 --> 00:02:56,934 these are the images that we built during our 53 00:02:56,934 --> 00:03:00,467 previous section. On the other hand, if we want to 54 00:03:00,467 --> 00:03:03,434 list out versions or instances of particular type 55 00:03:03,434 --> 00:03:06,901 of image, we can mention the image name followed 56 00:03:07,034 --> 00:03:12,601 by docker image command. Let's try and list all our Ubuntu images. 57 00:03:12,834 --> 00:03:14,834 Here we can also see the size 58 00:03:14,834 --> 00:03:17,667 of the image, which denotes the size they 59 00:03:17,667 --> 00:03:20,767 currently occupy on the storage of host machine. 60 00:03:21,201 --> 00:03:24,301 Of course, specifying the version number preceded 61 00:03:24,301 --> 00:03:28,334 by a colon narrows down the list just to one entry. 62 00:03:28,967 --> 00:03:31,834 Furthermore, if we want to see the full 63 00:03:31,834 --> 00:03:35,934 parts of truncated data, like image id, we can use 64 00:03:35,934 --> 00:03:38,901 --no -trunc flag as well, 65 00:03:38,901 --> 00:03:41,967 but be cautious while using it since it can make the 66 00:03:41,967 --> 00:03:45,701 results messy, really messy. 67 00:03:45,701 --> 00:03:48,567 [No Audio] 68 00:03:48,567 --> 00:03:52,167 Then we have docker pull, it pulls the specified 69 00:03:52,167 --> 00:03:56,234 image from Docker Hub to our Docker host. Here, we 70 00:03:56,234 --> 00:04:00,401 have provided nginx with :latest tag. 71 00:04:01,234 --> 00:04:05,067 So whichever image will have the latest tag on Docker 72 00:04:05,067 --> 00:04:07,934 Hub's nginx repository, will be pulled. 73 00:04:08,401 --> 00:04:11,901 As you can see, it has downloaded a newer version of 74 00:04:11,901 --> 00:04:14,267 nginx which is latest. 75 00:04:15,234 --> 00:04:17,567 Instead of latest, if we use 76 00:04:17,567 --> 00:04:21,267 'nginx:alpine', Docker Hub will provide an 77 00:04:21,267 --> 00:04:25,534 image with alpine tag. Now, if we grab a list of 78 00:04:25,534 --> 00:04:29,601 available nginx images on our host, we get two of them. 79 00:04:29,601 --> 00:04:32,201 First is the alpine one, which we just 80 00:04:32,201 --> 00:04:35,301 pulled and second is the latest version. 81 00:04:35,301 --> 00:04:40,167 As you can see, both of them vary majorly in terms of size. 82 00:04:40,201 --> 00:04:43,467 Alpine is like minimal nginx image, which is 83 00:04:43,467 --> 00:04:47,534 smaller in terms of size, since alpine as the base OS 84 00:04:47,534 --> 00:04:51,801 itself is smaller. Finally, if we want all 85 00:04:51,801 --> 00:04:55,701 variants of nginx images, say for testing purpose, 86 00:04:55,701 --> 00:05:00,101 we can hit the command with --all tags flag 87 00:05:00,101 --> 00:05:02,934 and we will receive the missing images 88 00:05:02,934 --> 00:05:07,667 from the repository. Once we list the nginx images now, 89 00:05:07,667 --> 00:05:10,001 it is clearly visible that these are 90 00:05:10,001 --> 00:05:12,501 different versions with different sizes. 91 00:05:12,501 --> 00:05:14,167 [No Audio] 92 00:05:14,167 --> 00:05:17,801 We are back to our Docker Hub dashboard, let's click on 93 00:05:17,801 --> 00:05:21,167 Create Repository option so we can make a repo and 94 00:05:21,167 --> 00:05:22,667 push images to it. 95 00:05:23,734 --> 00:05:25,601 On the left pane, Docker is 96 00:05:25,601 --> 00:05:28,801 generous enough to list out the steps to create a repo. 97 00:05:29,267 --> 00:05:32,034 First of all, we are supposed to provide a 98 00:05:32,034 --> 00:05:35,301 namespace for our repositories, so that we don't 99 00:05:35,301 --> 00:05:38,534 have to make the name unique across the globe. 100 00:05:39,167 --> 00:05:42,667 Generally, namespace is same as the username. 101 00:05:42,934 --> 00:05:45,967 Now, let's name our repository. 102 00:05:47,234 --> 00:05:51,934 We are naming it 'repo-nginx'. You can name it anything you like. 103 00:05:51,934 --> 00:05:53,701 [No Audio] 104 00:05:53,701 --> 00:05:56,434 Next step is the description of this repo. 105 00:05:56,934 --> 00:06:00,201 Here. As you can see, we have given a short and 106 00:06:00,201 --> 00:06:02,101 sweet description about this repo. 107 00:06:02,567 --> 00:06:06,001 If you want to describe your repo in much more detail, you can 108 00:06:06,001 --> 00:06:08,734 jump to the full description section of this repo. 109 00:06:08,834 --> 00:06:11,567 And in the final step, we can set the visibility 110 00:06:11,567 --> 00:06:13,301 permission for our repository. 111 00:06:14,367 --> 00:06:16,867 Docker offers one free private repo 112 00:06:16,867 --> 00:06:18,767 and unlimited public repo with 113 00:06:18,767 --> 00:06:20,401 free Docker Hub account. 114 00:06:20,867 --> 00:06:23,134 So do your choices wisely. 115 00:06:23,501 --> 00:06:26,534 We don't need private repos for now, so we 116 00:06:26,534 --> 00:06:29,034 will select the public visibility for this repo. 117 00:06:29,167 --> 00:06:31,634 Now let's create the repo by pressing Create 118 00:06:31,634 --> 00:06:33,601 button at the end of the page. 119 00:06:33,601 --> 00:06:35,701 [No Audio] 120 00:06:35,701 --> 00:06:39,501 We have successfully created our repo-nginx. 121 00:06:40,067 --> 00:06:43,501 As we can see, that there are some tabs above the short 122 00:06:43,501 --> 00:06:47,301 description of the repo, first one is Repo Info tab, 123 00:06:47,434 --> 00:06:49,967 it displays the basic information about our 124 00:06:49,967 --> 00:06:54,334 repo-nginx such as its visibility, which is 125 00:06:54,334 --> 00:06:57,834 public, and short description about it. 126 00:06:58,401 --> 00:07:00,567 Second one is tags, 127 00:07:00,867 --> 00:07:03,034 you can add multiple images under a 128 00:07:03,034 --> 00:07:06,101 single repo separated by different tags. 129 00:07:06,401 --> 00:07:09,501 If you do not specify any tag for the image, 130 00:07:09,801 --> 00:07:12,634 it will by default take latest tag. 131 00:07:12,867 --> 00:07:17,934 Third one is collaborators, it consists of a user or a list of 132 00:07:17,934 --> 00:07:21,434 user whom the owner of the private repo wants to 133 00:07:21,434 --> 00:07:24,434 grant the read, write, or admin access. 134 00:07:25,401 --> 00:07:30,467 Next and the fourth one is Webhooks, Webhook is a HTTP 135 00:07:30,467 --> 00:07:34,167 callback POST request. It can be used to notify 136 00:07:34,167 --> 00:07:37,134 user, services or other applications about the 137 00:07:37,134 --> 00:07:39,734 newly pushed image to the repo. 138 00:07:40,034 --> 00:07:44,834 Last one is the settings of the repo, here, user can change the 139 00:07:44,834 --> 00:07:47,967 visibility permission of the repo and can also 140 00:07:47,967 --> 00:07:51,601 delete the repo from user's Docker Hub account permanently. 141 00:07:52,467 --> 00:07:54,834 Now, as you can see, you can pull the 142 00:07:54,834 --> 00:07:58,301 images available under the repo-nginx repository. 143 00:07:58,467 --> 00:08:01,601 By using this specific docker pull command, 144 00:08:01,601 --> 00:08:07,167 docker pull ceruleancanvas/repo-nginx 145 00:08:07,167 --> 00:08:09,801 and store them on your machines. 146 00:08:10,401 --> 00:08:14,234 Since this is your first ever repository created on Docker Hub, 147 00:08:14,234 --> 00:08:17,234 let's self indulge ourselves by giving it a star. 148 00:08:17,234 --> 00:08:19,067 [No Audio] 149 00:08:19,067 --> 00:08:22,301 Starring repo is a way to show that you liked the 150 00:08:22,301 --> 00:08:26,434 repository and you can remember it for your future references. 151 00:08:27,567 --> 00:08:29,967 Now let's switch back to the terminal. 152 00:08:29,967 --> 00:08:32,601 Before pushing an image to Docker Registry, 153 00:08:32,601 --> 00:08:35,701 we need to log in again to Docker Hub using 154 00:08:35,701 --> 00:08:37,767 docker login command interactively. 155 00:08:37,767 --> 00:08:39,301 [No Audio] 156 00:08:39,301 --> 00:08:42,333 Here, we have been asked to enter our Docker Hub 157 00:08:42,333 --> 00:08:45,467 login credentials, we will enter our username 158 00:08:45,467 --> 00:08:48,234 which is ceruleancanvas and its password. 159 00:08:48,234 --> 00:08:51,567 We have successfully logged in our account with a warning 160 00:08:51,567 --> 00:08:54,933 which says that our Docker Hub password is stored 161 00:08:54,933 --> 00:09:01,401 unencrypted in config.json file on our machine for future references. 162 00:09:01,934 --> 00:09:03,767 We are okay with it for now, 163 00:09:03,767 --> 00:09:08,434 so we will ignore the warning and proceed to the next step. 164 00:09:09,567 --> 00:09:13,667 Now we will tag a local image nginx:latest 165 00:09:13,667 --> 00:09:15,434 into a new image. 166 00:09:15,767 --> 00:09:19,134 We will specify where we want to push this image, 167 00:09:19,134 --> 00:09:23,167 we can write the hostname on which the registry is hosting, which 168 00:09:23,201 --> 00:09:25,367 is ceruleancanvas for us. 169 00:09:26,434 --> 00:09:30,901 Now, we will mention the registry name in which we want to push 170 00:09:30,901 --> 00:09:34,201 the image that is repo-nginx. 171 00:09:34,767 --> 00:09:38,134 You want to give your own custom tag to the image such as 172 00:09:38,134 --> 00:09:40,601 cc-nginx for this example. 173 00:09:40,601 --> 00:09:44,301 Or, if you don't mention any tag for the image, 174 00:09:44,301 --> 00:09:46,467 it will take latest by default. 175 00:09:47,001 --> 00:09:49,667 This two stage format is mandatory to 176 00:09:49,667 --> 00:09:52,201 push an image to a public repository. 177 00:09:52,467 --> 00:09:57,267 Now let's check out our newly tagged image by listing all 178 00:09:57,267 --> 00:10:01,967 images on our machine. There you are, we have original 179 00:10:01,967 --> 00:10:04,667 nginx latest image and newly tagged 180 00:10:04,667 --> 00:10:10,767 'ceruleancanvas/repo-nginx:cc-nginx image'. 181 00:10:11,301 --> 00:10:13,267 But did you notice something, 182 00:10:13,534 --> 00:10:16,734 these two images have the same image ID. 183 00:10:17,101 --> 00:10:21,234 It is because docker tag command has created an alias for your 184 00:10:21,234 --> 00:10:25,434 image as its new image name. So that the original 185 00:10:25,434 --> 00:10:28,601 image will be untouched and all of its changes can 186 00:10:28,601 --> 00:10:30,834 be performed to the new alias image. 187 00:10:32,001 --> 00:10:37,834 Now, let's push the ceruleancanvas/repo-nginx:cc-nginx 188 00:10:37,834 --> 00:10:41,834 to all repo-nginx, using docker push command. 189 00:10:42,167 --> 00:10:44,201 We have already specified the path 190 00:10:44,201 --> 00:10:47,167 for the destination location in image name. 191 00:10:48,001 --> 00:10:51,434 As we can see, Docker is pushing each layer of the 192 00:10:51,434 --> 00:10:54,334 original latest image at this end. 193 00:10:54,801 --> 00:10:58,967 On the other hand, Docker daemon will stack all of these layers 194 00:10:58,967 --> 00:11:02,301 sequentially and create a new image with the tag 195 00:11:02,301 --> 00:11:05,234 cc-nginx in the repo-nginx. 196 00:11:05,234 --> 00:11:06,934 At the end of 197 00:11:06,934 --> 00:11:09,001 At the end of the process, we got our 198 00:11:09,001 --> 00:11:12,401 new image digest identifier of the push image. 199 00:11:13,434 --> 00:11:15,667 Now let's switch back to Docker Hub account 200 00:11:15,667 --> 00:11:19,034 to verify that our repo has been successfully pushed, 201 00:11:19,301 --> 00:11:22,567 we will navigate to the repo-nginx repository, 202 00:11:22,734 --> 00:11:25,334 go to tags and we have 203 00:11:25,334 --> 00:11:29,101 successfully pushed the image. Image tag, size, and 204 00:11:29,134 --> 00:11:31,134 updated name are mentioned here. 205 00:11:31,134 --> 00:11:33,801 In next lecture, we will dig deeper 206 00:11:33,801 --> 00:11:37,667 into the image by inspecting it and looking at its history.