1 00:00:02,520 --> 00:00:10,250 ‫This lecture is the answers to the assignment lecture right before this one for managing multiple 2 00:00:10,250 --> 00:00:11,160 ‫containers. 3 00:00:11,180 --> 00:00:17,810 ‫This is basically just a recording of me thinking out loud and walking through the assignment. You 4 00:00:17,810 --> 00:00:22,310 ‫might have slightly different commands. That's OK as long as you got to the end result of the three 5 00:00:22,310 --> 00:00:26,210 ‫different containers, running the three different images, with the required parameters. 6 00:00:26,210 --> 00:00:28,310 ‫Here we go. 7 00:00:28,670 --> 00:00:32,240 ‫I'll probably want to run the MySQL one first. 8 00:00:34,790 --> 00:00:43,220 ‫mysql but I'm going to need to detach it and then open up port 9 00:00:45,780 --> 00:00:56,030 ‫3306. Then I'm going to give it a name called db. Then I'm also going to throw in this environment 10 00:00:56,030 --> 00:00:57,020 ‫variable. 11 00:01:07,860 --> 00:01:10,470 ‫That should do it. 12 00:01:10,480 --> 00:01:14,020 ‫Oh I have too many dashes on the e. 13 00:01:15,070 --> 00:01:15,980 ‫OK. 14 00:01:16,090 --> 00:01:21,830 ‫Now I shall do docker container log mysql. 15 00:01:22,000 --> 00:01:23,130 ‫Nope. Sorry. db 16 00:01:29,180 --> 00:01:32,180 ‫logs not log. 17 00:01:33,260 --> 00:01:38,850 ‫So I don't...let's see, I'm not sure...I don't see it yet. 18 00:01:38,880 --> 00:01:41,660 ‫I don't see the password. 19 00:01:41,660 --> 00:01:42,920 ‫It's pretty obvious. 20 00:01:47,310 --> 00:01:49,350 ‫Let me try it again. 21 00:01:57,110 --> 00:02:01,980 ‫There we go. Generated root password right there. 22 00:02:03,110 --> 00:02:05,540 ‫I want to copy that for later. 23 00:02:05,540 --> 00:02:07,550 ‫I don't actually need it for this assignment. 24 00:02:07,550 --> 00:02:13,490 ‫But that's how I would get the password if I needed to log into that MySQL server. All right. We're going to run 25 00:02:13,490 --> 00:02:15,870 ‫the next one -- docker container 26 00:02:15,920 --> 00:02:17,150 ‫run 27 00:02:17,300 --> 00:02:18,830 ‫detached 28 00:02:18,830 --> 00:02:20,010 ‫name 29 00:02:20,150 --> 00:02:22,220 ‫webserver 30 00:02:23,240 --> 00:02:25,040 ‫and then port. 31 00:02:25,070 --> 00:02:32,840 ‫It's going to be the Apache one so port 8080 on my host is going to go to 80 in my container. Then 32 00:02:32,840 --> 00:02:37,160 ‫httpd. 33 00:02:37,970 --> 00:02:45,310 ‫OK, and if I do a docker ps, both of those should be running. I can see on the right that their proper ports 34 00:02:45,310 --> 00:02:52,930 ‫are redirecting from my host into my container. That's what that little arrow means. Then, let's see one more 35 00:02:52,930 --> 00:02:56,160 ‫docker container run. 36 00:02:56,300 --> 00:03:10,980 ‫Give it a name of proxy. I'm going to have that listed on port 80 and forward to port 80. It's detached. And proper name. 37 00:03:11,450 --> 00:03:17,200 ‫OK I think that one's good. docker ps 38 00:03:21,540 --> 00:03:26,450 ‫You'll notice, by the way, that I'm typing docker ps, not docker container 39 00:03:26,460 --> 00:03:27,240 ‫ls 40 00:03:27,240 --> 00:03:31,540 ‫just because old habits die hard and the old command is docker 41 00:03:31,540 --> 00:03:35,950 ‫ps. But it still works. All right. 42 00:03:36,000 --> 00:03:41,490 ‫All three are running. All the ports are forwarding. Properly named them. 43 00:03:43,700 --> 00:03:44,360 ‫And 44 00:03:47,720 --> 00:03:49,190 ‫I'm actually going to... 45 00:03:58,040 --> 00:04:03,080 ‫I'm actually going to test their ports. If I do curl localhost, 46 00:04:03,600 --> 00:04:14,350 ‫it should give me back the nginx. If I curl...let's see localhost 8080, I should get back the Apache. 47 00:04:18,560 --> 00:04:19,050 ‫All right. 48 00:04:19,060 --> 00:04:23,000 ‫Those are open. 49 00:04:23,460 --> 00:04:23,690 ‫All right. 50 00:04:23,700 --> 00:04:27,740 ‫Now I need to clean them up. I want to do docker container 51 00:04:28,530 --> 00:04:34,760 ‫stop 52 00:04:36,960 --> 00:04:37,740 ‫Oh that's right. 53 00:04:37,740 --> 00:04:38,840 ‫I didn't name them that. 54 00:04:38,880 --> 00:04:40,440 ‫That's silly. 55 00:04:40,500 --> 00:04:50,580 ‫I'm just going to use tab to give me tab completion. I can do this one and this one. 56 00:04:50,630 --> 00:04:50,920 ‫Now. 57 00:04:54,880 --> 00:04:55,650 ‫OK. 58 00:04:55,920 --> 00:04:59,870 ‫All three are stopped. docker ps -a. 59 00:05:00,360 --> 00:05:01,030 ‫Yep. 60 00:05:01,230 --> 00:05:06,360 ‫All three of them. I could have also done docker container ls -a. 61 00:05:07,410 --> 00:05:08,310 ‫Same thing. 62 00:05:08,320 --> 00:05:10,170 ‫Now I need to remove them. 63 00:05:10,170 --> 00:05:10,860 ‫I'm going to do a 64 00:05:10,860 --> 00:05:15,190 ‫docker container rm. 65 00:05:15,460 --> 00:05:17,280 ‫I'm going to use tab completion again 66 00:05:20,430 --> 00:05:22,980 ‫and remove them. 67 00:05:23,010 --> 00:05:28,360 ‫docker ps -a...nothing there. docker images. 68 00:05:28,670 --> 00:05:36,030 ‫This is a new command actually. image ls. That shows me the three different images that are still there. 69 00:05:36,180 --> 00:05:36,930 ‫OK. 70 00:05:37,350 --> 00:05:40,460 ‫Everything's cleaned up. That's my assignment.