1 00:00:06,870 --> 00:00:09,011 - All right, let's run some containers. 2 00:00:09,011 --> 00:00:10,740 The Podman command provides 3 00:00:10,740 --> 00:00:13,533 nearly all functionality that is provided by Docker. 4 00:00:15,240 --> 00:00:18,940 Actually, the Podman command is easy to get started with 5 00:00:18,940 --> 00:00:21,586 and for that reason, in the remainder of this lesson 6 00:00:21,586 --> 00:00:23,850 I will use the Podman command only. 7 00:00:23,850 --> 00:00:25,710 If you want to use Docker, that's okay. 8 00:00:25,710 --> 00:00:29,490 Just replace Docker with Podman and it will work. 9 00:00:29,490 --> 00:00:31,560 Because in fact the Podman project 10 00:00:31,560 --> 00:00:34,200 contains features that are available 11 00:00:34,200 --> 00:00:36,450 in Docker and not in Podman. 12 00:00:36,450 --> 00:00:39,600 They consider that Burkes and they will fix that. 13 00:00:39,600 --> 00:00:41,500 And that is why they are very similar. 14 00:00:42,502 --> 00:00:44,940 That's also why all commands in this lesson 15 00:00:44,940 --> 00:00:46,410 are completely compatible 16 00:00:46,410 --> 00:00:48,960 with the equivalent Docker command. 17 00:00:48,960 --> 00:00:50,880 And as I mentioned, if you're on Docker 18 00:00:50,880 --> 00:00:52,683 just replace Podman with Docker. 19 00:00:54,810 --> 00:00:57,360 One tip, if you're going to use a Podman command 20 00:00:57,360 --> 00:00:59,460 options that are passed to the Podman command 21 00:00:59,460 --> 00:01:01,740 need to be specified before the name of the image. 22 00:01:01,740 --> 00:01:03,060 That's a very common error 23 00:01:03,060 --> 00:01:05,095 and I wanted to mention that separately. 24 00:01:05,095 --> 00:01:07,290 And that is because anything specified 25 00:01:07,290 --> 00:01:10,650 after the name of the image is interpreted 26 00:01:10,650 --> 00:01:12,360 as an argument to the command 27 00:01:12,360 --> 00:01:14,962 that runs inside the container. 28 00:01:14,962 --> 00:01:16,773 Let's run some containers. 29 00:01:19,110 --> 00:01:21,990 So to start with, I'm using Podman alone 30 00:01:21,990 --> 00:01:26,133 minus D ends in X minus minus name is my-web. 31 00:01:29,100 --> 00:01:32,881 And then what do we see? We see a lot, 32 00:01:32,881 --> 00:01:35,907 but let's figure out what's going on. Podman PS 33 00:01:39,840 --> 00:01:43,020 and oh boy, Podman PS isn't showing anything. 34 00:01:43,020 --> 00:01:46,980 What is going on? Well, Podman logs minus L 35 00:01:46,980 --> 00:01:50,610 allows us to investigate the logs. And what do we see here? 36 00:01:50,610 --> 00:01:52,350 These are the logs that were generated 37 00:01:52,350 --> 00:01:54,270 by the container application 38 00:01:54,270 --> 00:01:55,660 and the logs are telling me 39 00:01:56,790 --> 00:01:59,190 name my-web not found. 40 00:01:59,190 --> 00:02:02,489 Now what is wrong here? Well, the wrong part is 41 00:02:02,489 --> 00:02:04,954 where I'm specifying minus minus name is my-web 42 00:02:04,954 --> 00:02:07,560 all the way to the end of the command. 43 00:02:07,560 --> 00:02:11,880 Minus, minus name is my-web is an argument to podman-run. 44 00:02:11,880 --> 00:02:15,480 And arguments to podman-run should always come before 45 00:02:15,480 --> 00:02:18,093 the name of the container image and not after. 46 00:02:18,990 --> 00:02:21,516 So if you run it again then we should be better 47 00:02:21,516 --> 00:02:24,540 and Podman PS is showing that right now 48 00:02:24,540 --> 00:02:27,393 it is, it is running and that's good. 49 00:02:30,150 --> 00:02:32,763 Next I want to use Podman and run Busybox. 50 00:02:33,750 --> 00:02:36,178 Busybox is a minimal cloud image 51 00:02:36,178 --> 00:02:38,520 and is minimal cloud image can be used 52 00:02:38,520 --> 00:02:41,310 as a foundation for your own images. 53 00:02:41,310 --> 00:02:43,110 So here we can see it's trying to pull 54 00:02:43,110 --> 00:02:44,910 Docker dot IO library Busybox, 55 00:02:44,910 --> 00:02:47,160 that's the fully qualified container name. 56 00:02:47,160 --> 00:02:48,424 And that seems to be okay. 57 00:02:48,424 --> 00:02:51,240 And what happens if you use Podman PS? 58 00:02:51,240 --> 00:02:54,243 Now Podman PS is only showing ends in X. 59 00:02:55,290 --> 00:02:57,420 Now in order to further investigate, 60 00:02:57,420 --> 00:03:00,000 we need Podman PS minus A 61 00:03:00,000 --> 00:03:03,420 because Podman PS is showing currently running containers 62 00:03:03,420 --> 00:03:05,742 Podman PS minus A is showing also containers 63 00:03:05,742 --> 00:03:08,100 that have been started in the past. 64 00:03:08,100 --> 00:03:09,270 And there on the last line 65 00:03:09,270 --> 00:03:11,910 we can see that this Busybox container 66 00:03:11,910 --> 00:03:15,887 was created 17 seconds ago and exited 18 seconds ago. 67 00:03:15,887 --> 00:03:17,546 Now what is going on? 68 00:03:17,546 --> 00:03:19,950 Well the Busybox container is configured 69 00:03:19,950 --> 00:03:22,650 to run an SH command. 70 00:03:22,650 --> 00:03:25,770 That's a default command and that is running a shell. 71 00:03:25,770 --> 00:03:28,230 But if you run a shell, it needs to be connected 72 00:03:28,230 --> 00:03:30,900 to standard input, standard output, standard error. 73 00:03:30,900 --> 00:03:33,030 And neither of these is the case. 74 00:03:33,030 --> 00:03:35,418 Well just running Podman run Busybox. 75 00:03:35,418 --> 00:03:37,470 That is why the Busybox container 76 00:03:37,470 --> 00:03:39,813 has been started and immediately exited. 77 00:03:41,220 --> 00:03:42,828 If you wanted to do something 78 00:03:42,828 --> 00:03:46,230 then you rather use Podman run minus IT. 79 00:03:46,230 --> 00:03:50,550 Where minus IT is opening an interactive terminal 80 00:03:50,550 --> 00:03:54,030 on Busybox and we are using SH and there we go. 81 00:03:54,030 --> 00:03:58,470 Here we are inside the Busybox environment. 82 00:03:58,470 --> 00:04:00,537 So if I use a command like PS AUX, 83 00:04:00,537 --> 00:04:03,690 which happens to be available in this container image. 84 00:04:03,690 --> 00:04:07,200 I see what is visible from within the name space 85 00:04:07,200 --> 00:04:08,719 that is started by this container, 86 00:04:08,719 --> 00:04:12,720 the restricted environment. That is what this is all about. 87 00:04:12,720 --> 00:04:15,463 Now let me use Control P, Control Q to disconnect 88 00:04:15,463 --> 00:04:20,463 and let's do Podman exec minus IT my-web at SH. 89 00:04:22,273 --> 00:04:23,640 Hey, what is that? 90 00:04:23,640 --> 00:04:25,710 Well, we previously have already started 91 00:04:25,710 --> 00:04:28,440 the my-web container and now I'm using 92 00:04:28,440 --> 00:04:33,440 Podman exec to run SH inside my web 93 00:04:33,878 --> 00:04:36,090 in an interactive terminal. 94 00:04:36,090 --> 00:04:38,100 So right now we are in my-web 95 00:04:38,100 --> 00:04:40,530 and if I use PS AUX then what do we see? 96 00:04:40,530 --> 00:04:42,213 We see CPS command not found. 97 00:04:43,200 --> 00:04:44,370 Now that is something that you will 98 00:04:44,370 --> 00:04:47,940 very commonly come across while running containers. 99 00:04:47,940 --> 00:04:51,060 A container is not a full Linux installation. 100 00:04:51,060 --> 00:04:54,900 A container is an application, and within that application 101 00:04:54,900 --> 00:04:58,050 common Linux tools are not always available. 102 00:04:58,050 --> 00:05:01,530 And that is why I see PS command not found. 103 00:05:01,530 --> 00:05:04,234 This container image doesn't have the PS utility. 104 00:05:04,234 --> 00:05:07,170 The only way to figure out what is going on 105 00:05:07,170 --> 00:05:10,365 is when you type LS on PROC where on the left hand side 106 00:05:10,365 --> 00:05:12,090 you see the PID directory, 107 00:05:12,090 --> 00:05:15,090 so one the 24, the 25, the 26. 108 00:05:15,090 --> 00:05:17,220 These are the processes that are running. 109 00:05:17,220 --> 00:05:19,290 And if you wanna know what is going on 110 00:05:19,290 --> 00:05:24,290 well try proc one CMD line do a kettle net 111 00:05:24,540 --> 00:05:28,260 and there you will see that this is an Nginx master process. 112 00:05:28,260 --> 00:05:31,685 Nginx minus G daemon off that's the process. 113 00:05:31,685 --> 00:05:33,780 That's how it works in containers. 114 00:05:33,780 --> 00:05:36,633 Containers are a restricted environments. 115 00:05:37,500 --> 00:05:41,160 I'm using exit in order to close the shell 116 00:05:41,160 --> 00:05:43,650 that I just started with Podman exec 117 00:05:43,650 --> 00:05:48,180 and adjust the Podman PS to verify that my Nginx 118 00:05:48,180 --> 00:05:50,580 as well as my Busybox are still running. 119 00:05:50,580 --> 00:05:54,690 They are and now I can use Podman inspect on my-web 120 00:05:54,690 --> 00:05:56,033 as the last command. 121 00:05:56,033 --> 00:05:57,043 What is that? 122 00:05:57,043 --> 00:05:59,026 Podman inspect is a nice command 123 00:05:59,026 --> 00:06:01,350 that will show you different details 124 00:06:01,350 --> 00:06:03,363 about currently running containers. 125 00:06:04,380 --> 00:06:06,810 Normally a lot of output will follow, 126 00:06:06,810 --> 00:06:09,300 so just pipe the output through the less command 127 00:06:09,300 --> 00:06:11,800 and there you can see everything that is going on. 128 00:06:13,470 --> 00:06:15,460 As I told you, a lot of output 129 00:06:16,350 --> 00:06:18,630 telling you exactly what this container is doing. 130 00:06:18,630 --> 00:06:20,040 This is the most important part 131 00:06:20,040 --> 00:06:22,350 where we can see the path and the arguments. 132 00:06:22,350 --> 00:06:24,600 Giving information about the default command 133 00:06:24,600 --> 00:06:26,350 that was started by this container.