1 00:00:00,000 --> 00:00:11,940 Containers are based on images, and you better should know a bit about images as well. 2 00:00:11,940 --> 00:00:18,440 So before running a container, the container image is fetched and stored locally. 3 00:00:18,440 --> 00:00:22,799 All images are stored on the container host by default, and you can use Docker images 4 00:00:22,799 --> 00:00:25,480 for a list of current images. 5 00:00:25,480 --> 00:00:30,280 The command docker inspect images is a cool command because it will show you exactly what 6 00:00:30,280 --> 00:00:33,439 happens while starting the container. 7 00:00:33,439 --> 00:00:38,840 And if you don't need a specific container image anymore, you can use docker rmi followed 8 00:00:38,840 --> 00:00:42,660 by the name of the image to remove the image. 9 00:00:42,660 --> 00:00:45,599 It's also possible to work with custom images. 10 00:00:45,599 --> 00:00:49,360 To do so, you would use the docker file. 11 00:00:49,360 --> 00:00:54,000 On Red Hat-based Popman systems, container file is commonly used as an alternative name 12 00:00:54,080 --> 00:00:55,799 for docker file. 13 00:00:55,799 --> 00:01:00,799 For an example, you can check the docker file in the course Git repository. 14 00:01:00,799 --> 00:01:06,160 Now you can build your own container image based on the instructions in the docker file. 15 00:01:06,160 --> 00:01:08,760 Use docker build minus T image name. 16 00:01:08,760 --> 00:01:11,279 That's the name of the image that you want to create. 17 00:01:11,279 --> 00:01:16,419 Dot slash name of the docker file directory to build the container image. 18 00:01:16,419 --> 00:01:20,800 And after creating the image is added to the list of images on your system. 19 00:01:20,800 --> 00:01:22,400 Let me show you. 20 00:01:22,400 --> 00:01:25,440 So to start with, I want to show you docker images. 21 00:01:25,440 --> 00:01:28,160 These are the images that have been fetched so far. 22 00:01:28,160 --> 00:01:29,160 And do you see that? 23 00:01:29,160 --> 00:01:31,959 The busy box is only four megabytes. 24 00:01:31,959 --> 00:01:38,919 Now let's use docker inspect on NGINX. 25 00:01:38,919 --> 00:01:42,279 Well I would like to use it in a slightly different way. 26 00:01:42,279 --> 00:01:46,000 Let's use docker image inspect on NGINX. 27 00:01:46,000 --> 00:01:50,599 Because docker inspect, you don't tell docker what to expect, so it needs to guess. 28 00:01:50,599 --> 00:01:54,800 Docker image inspect, it knows that you want to inspect an image. 29 00:01:54,800 --> 00:02:00,199 Without the image, it will also find the container with the name NGINX and it will show you the 30 00:02:00,199 --> 00:02:02,559 configuration of that. 31 00:02:02,559 --> 00:02:08,360 Now here we can see the configuration behind the container image with the path variable, 32 00:02:08,360 --> 00:02:13,520 with the default commands that it is running, and more about what the container image is 33 00:02:13,520 --> 00:02:14,520 doing. 34 00:02:14,520 --> 00:02:18,399 And that can be very useful to figure out what is going to happen before you actually 35 00:02:18,399 --> 00:02:20,139 do it. 36 00:02:20,179 --> 00:02:23,179 Now let's go into the course git repository. 37 00:02:23,179 --> 00:02:31,139 To start with, I need to make it available here using git clone https://github.com 38 00:02:31,139 --> 00:02:35,820 slash Sander van Vugt slash Linux plus. 39 00:02:35,820 --> 00:02:40,619 All right, so in the Linux plus git repository, there's a subdirectory with the name dockerfile 40 00:02:40,619 --> 00:02:43,300 in which you find a dockerfile. 41 00:02:43,300 --> 00:02:44,820 So what is in this dockerfile? 42 00:02:44,820 --> 00:02:49,619 Well, a simple example of a dockerfile specifying from Alpine. 43 00:02:49,619 --> 00:02:55,020 So it's using Alpine, one of these base cloud image as a foundational image. 44 00:02:55,020 --> 00:02:56,940 Then we have the maintainer. 45 00:02:56,940 --> 00:02:58,139 That's for politeness sake. 46 00:02:58,139 --> 00:03:03,880 It's open source and an open source is always nice if you can find your original developer. 47 00:03:03,880 --> 00:03:06,380 Then we use add to add a file. 48 00:03:06,380 --> 00:03:11,339 It's kind of a dummy here, but it's an interesting way to show you how you can add a file to 49 00:03:11,339 --> 00:03:13,699 your container image. 50 00:03:13,699 --> 00:03:16,539 Then it is installing some cool software. 51 00:03:16,539 --> 00:03:22,619 The run command is running while you build your custom container image. 52 00:03:22,619 --> 00:03:28,220 So apk is the Alpine package manager is going to add bash as well as nmap. 53 00:03:28,220 --> 00:03:32,940 Then the entry point is specifying the default command, and this entry point works with the 54 00:03:32,940 --> 00:03:39,020 argument minus sn 172.17.0.0. 55 00:03:39,020 --> 00:03:48,860 So if I want to use it, I can use docker build minus t altmap. 56 00:03:48,860 --> 00:03:54,539 Minus t is a tag, and this tag is really the name that you are going to assign, and I'm 57 00:03:54,539 --> 00:03:56,979 doing that on dot. 58 00:03:56,979 --> 00:04:00,500 Now this is telling you that the legacy builder is defecated. 59 00:04:00,500 --> 00:04:01,500 Please ignore that. 60 00:04:01,500 --> 00:04:02,899 For now, it's still used. 61 00:04:02,899 --> 00:04:08,779 Now if I use docker images, then we can see that altmap is now available. 62 00:04:09,539 --> 00:04:15,899 And if I use docker run altmap, it is going to run its primary application. 63 00:04:15,899 --> 00:04:21,420 And its primary application is nmap, and here you can see that nmap is doing its work and 64 00:04:21,420 --> 00:04:24,079 might give us a result in a little bit. 65 00:04:24,079 --> 00:04:26,980 It's not about the result of the nmap application. 66 00:04:26,980 --> 00:04:32,420 It's about the fact that I created a container image that is running this application. 67 00:04:32,420 --> 00:04:33,899 Why would you want to do that? 68 00:04:33,899 --> 00:04:38,100 Well, containers are cool because they run in complete isolation. 69 00:04:38,100 --> 00:04:41,220 No risk for any other applications in your environment.