1 00:00:07,440 --> 00:00:10,590 - So in this video I will tell you about container images. 2 00:00:10,590 --> 00:00:13,830 The purpose of a container is to start an application. 3 00:00:13,830 --> 00:00:15,510 And a container image contains 4 00:00:15,510 --> 00:00:17,310 all of the dependencies that are required 5 00:00:17,310 --> 00:00:18,903 to start that application. 6 00:00:20,310 --> 00:00:23,520 Existing container images can be used to run containers, 7 00:00:23,520 --> 00:00:25,500 and images are provided through public 8 00:00:25,500 --> 00:00:28,170 as well as private image registries. 9 00:00:28,170 --> 00:00:31,230 Docker Hub, accessible at hub.docker.com, 10 00:00:31,230 --> 00:00:33,180 is the biggest public registry 11 00:00:33,180 --> 00:00:36,840 and the most commonly used registry as well. 12 00:00:36,840 --> 00:00:39,090 Let's check out Docker Hub before continuing. 13 00:00:41,460 --> 00:00:43,980 So this is hub.docker.com. 14 00:00:43,980 --> 00:00:45,420 You can create an account 15 00:00:45,420 --> 00:00:47,610 which offers a couple of benefits. 16 00:00:47,610 --> 00:00:49,350 If you are looking for a specific image 17 00:00:49,350 --> 00:00:51,870 you can also search for the image right here. 18 00:00:51,870 --> 00:00:54,330 So let's look for nginx, for instance. 19 00:00:54,330 --> 00:00:57,030 And what do we see? We see verified content. 20 00:00:57,030 --> 00:00:59,970 Verified content are reliable images 21 00:00:59,970 --> 00:01:01,020 which has been verified 22 00:01:01,020 --> 00:01:03,360 and there is normally some company behind. 23 00:01:03,360 --> 00:01:05,460 There's also community images. 24 00:01:05,460 --> 00:01:08,250 And the community images, well, if you see 10,000, 25 00:01:08,250 --> 00:01:10,860 that means 10,000 or more. 26 00:01:10,860 --> 00:01:12,990 Let's have a look at the verified content. 27 00:01:12,990 --> 00:01:15,480 So here we can see the Docker image, 28 00:01:15,480 --> 00:01:18,570 including the command to fetch the image 29 00:01:18,570 --> 00:01:20,220 and a quick reference. 30 00:01:20,220 --> 00:01:23,520 So normally the image has some documentation 31 00:01:23,520 --> 00:01:25,800 associated to it as well. 32 00:01:25,800 --> 00:01:29,520 And in some cases, this documentation is really very useful. 33 00:01:29,520 --> 00:01:31,980 Here you can see that the documentation is very detailed 34 00:01:31,980 --> 00:01:35,370 and is really helpful in running the nginx container, 35 00:01:35,370 --> 00:01:37,080 that's not always the case. 36 00:01:37,080 --> 00:01:38,760 If you're ever looking for images, 37 00:01:38,760 --> 00:01:40,320 have a look at the Docker website. 38 00:01:40,320 --> 00:01:42,000 It's the best way to find your images 39 00:01:42,000 --> 00:01:44,403 and much more convenient than a command line. 40 00:01:46,590 --> 00:01:48,810 So while running containers, the required images 41 00:01:48,810 --> 00:01:51,660 are fetched automatically and stored locally. 42 00:01:51,660 --> 00:01:54,510 And to find images you can use the search features 43 00:01:54,510 --> 00:01:55,860 on the image registry 44 00:01:55,860 --> 00:01:58,233 or the docker or podman search command. 45 00:01:59,220 --> 00:02:02,190 And to fetch an image, you can either run the container, 46 00:02:02,190 --> 00:02:03,780 which will automatically fetch it, 47 00:02:03,780 --> 00:02:06,450 or use docker or podman pull to pull the image 48 00:02:06,450 --> 00:02:08,223 without running it as a container. 49 00:02:09,180 --> 00:02:10,680 After pulling some images 50 00:02:10,680 --> 00:02:13,290 you can use docker or podman images 51 00:02:13,290 --> 00:02:15,270 which will show images currently installed 52 00:02:15,270 --> 00:02:17,430 and available for the current user. 53 00:02:17,430 --> 00:02:18,273 Let me show you. 54 00:02:21,510 --> 00:02:24,510 So for this podman demo I'm going to leave my root shell 55 00:02:24,510 --> 00:02:27,750 because we don't need root privileges to run containers. 56 00:02:27,750 --> 00:02:29,940 And running containers from a root shell 57 00:02:29,940 --> 00:02:33,060 is not the best practice that's available. 58 00:02:33,060 --> 00:02:35,214 Now this is centos and on centos 59 00:02:35,214 --> 00:02:37,170 podman is installed by default, 60 00:02:37,170 --> 00:02:38,880 that makes it very easy. 61 00:02:38,880 --> 00:02:41,910 So if I use podman search nginx 62 00:02:41,910 --> 00:02:44,700 then it's going to search in the default registries 63 00:02:44,700 --> 00:02:46,830 and it is showing all the registries 64 00:02:46,830 --> 00:02:49,470 where it has found the image. 65 00:02:49,470 --> 00:02:52,650 Now, in podman, multiple registries are pre-configured. 66 00:02:52,650 --> 00:02:53,880 If you are using Docker, 67 00:02:53,880 --> 00:02:56,070 docker is by default going to the Docker Hub 68 00:02:56,070 --> 00:02:58,950 and you will just see the image name. 69 00:02:58,950 --> 00:03:01,950 Now what we see here is the nginx image 70 00:03:01,950 --> 00:03:04,560 that we have just seen in the webpage as well, 71 00:03:04,560 --> 00:03:09,273 and if I want to fetch it, well, I can use podman pull. 72 00:03:11,310 --> 00:03:14,910 Now, podman pull can be fo followed by a short image name 73 00:03:14,910 --> 00:03:16,980 but the nicer way of doing it 74 00:03:16,980 --> 00:03:19,140 is the fully qualified image name, 75 00:03:19,140 --> 00:03:24,140 so podman pull docker.io/library/nginx. 76 00:03:25,530 --> 00:03:27,660 Why the fully qualified image name? 77 00:03:27,660 --> 00:03:30,870 Well, because there's more than just the Docker registry 78 00:03:30,870 --> 00:03:33,300 and this allows you to identify 79 00:03:33,300 --> 00:03:36,000 exactly which image you want to use. 80 00:03:36,000 --> 00:03:38,040 Here we can see the image being pulled, 81 00:03:38,040 --> 00:03:39,930 the multiple layers of the image. 82 00:03:39,930 --> 00:03:42,900 That's because this nginx is probably based on some 83 00:03:42,900 --> 00:03:46,140 other container images that are managed by somebody else, 84 00:03:46,140 --> 00:03:49,410 and all of these layers are managed independently. 85 00:03:49,410 --> 00:03:51,690 Now, I can use my podman images command 86 00:03:51,690 --> 00:03:54,390 and the podman images command is showing 87 00:03:54,390 --> 00:03:57,150 the image available on the system 88 00:03:57,150 --> 00:04:00,780 with the size of 146 megabytes. 89 00:04:00,780 --> 00:04:03,060 There's no real needs to do podman pull 90 00:04:03,060 --> 00:04:05,730 before actually you're running your container, 91 00:04:05,730 --> 00:04:06,990 but I wanted to show you 92 00:04:06,990 --> 00:04:09,030 a little bit about managing images. 93 00:04:09,030 --> 00:04:11,640 Now that you know how to work with images 94 00:04:11,640 --> 00:04:13,593 let's learn about learning containers.