1 00:00:00,000 --> 00:00:04,200 [Intro Music] 2 00:00:04,290 --> 00:00:06,030 Alright, let's go on. And let's 3 00:00:06,030 --> 00:00:07,920 first quickly summarize what we did 4 00:00:07,920 --> 00:00:10,050 in previous lectures. We have used 5 00:00:10,050 --> 00:00:11,910 the mongo image, and we have 6 00:00:11,910 --> 00:00:14,250 created different containers, mongo 7 00:00:14,250 --> 00:00:16,739 containers based on that image. And 8 00:00:16,739 --> 00:00:19,260 we have seen that every container 9 00:00:19,350 --> 00:00:21,090 will actually have its own 10 00:00:21,120 --> 00:00:23,550 database. And when you create a new 11 00:00:23,550 --> 00:00:25,290 databases, collections, records 12 00:00:25,320 --> 00:00:27,480 inside of that container, it will 13 00:00:27,480 --> 00:00:30,030 belong only to that container. And 14 00:00:30,060 --> 00:00:32,189 as soon as this container goes 15 00:00:32,220 --> 00:00:34,260 away, it is stopped or removed, 16 00:00:34,410 --> 00:00:36,450 then this database is removed as 17 00:00:36,450 --> 00:00:38,550 well. But very often, especially 18 00:00:38,550 --> 00:00:40,320 during development process, you 19 00:00:40,320 --> 00:00:42,630 need to have persistent database on 20 00:00:42,630 --> 00:00:44,790 your computer and have access to it 21 00:00:44,790 --> 00:00:46,380 from different containers that you 22 00:00:46,380 --> 00:00:48,810 start. And we have explored that it 23 00:00:48,810 --> 00:00:50,670 is possible to achieve this using 24 00:00:50,730 --> 00:00:53,640 volume mapping. And in such case, 25 00:00:53,670 --> 00:00:55,410 different containers that were 26 00:00:55,410 --> 00:00:57,810 running mongo, were able to work 27 00:00:57,840 --> 00:01:00,420 with the same database. Let's now 28 00:01:00,420 --> 00:01:02,520 proceed and next let's try to 29 00:01:02,520 --> 00:01:04,709 create the 'wordpress' container. 30 00:01:04,860 --> 00:01:07,260 WordPress is a very popular CMS, 31 00:01:07,260 --> 00:01:09,600 Content Management System; and it 32 00:01:09,600 --> 00:01:11,370 is used very often. There are a lot 33 00:01:11,370 --> 00:01:12,840 of custom templates that you're 34 00:01:12,840 --> 00:01:14,340 able to use and you're able to 35 00:01:14,340 --> 00:01:16,560 create the website pretty fast and 36 00:01:16,560 --> 00:01:18,930 quickly using WordPress. WordPress 37 00:01:18,960 --> 00:01:22,200 uses PHP and MySQL. And that means 38 00:01:22,200 --> 00:01:24,120 that WordPress requires working 39 00:01:24,120 --> 00:01:27,090 connection to MySQL database. 40 00:01:27,360 --> 00:01:29,730 Alright, let's now create container 41 00:01:29,790 --> 00:01:31,980 using wordpress image, and let's 42 00:01:32,040 --> 00:01:33,420 immediately use 'docker run' 43 00:01:33,420 --> 00:01:35,580 command with wordpress image as 44 00:01:35,610 --> 00:01:38,280 argument. Let's do so. 'docker run 45 00:01:38,520 --> 00:01:42,060 wordpress'. Unable to find image: 46 00:01:42,090 --> 00:01:44,040 'wordpress:latest' locally. As 47 00:01:44,040 --> 00:01:46,260 usually pulling 'fs' layers from 48 00:01:46,260 --> 00:01:48,300 Docker Hub. Let's wait a bit and 49 00:01:48,330 --> 00:01:49,770 I'll get back to you when this 50 00:01:49,770 --> 00:01:51,840 process will be finished. All 51 00:01:51,840 --> 00:01:53,550 right, image was successfully 52 00:01:53,550 --> 00:01:55,560 pulled and afterwards WordPress 53 00:01:55,620 --> 00:01:57,990 tried to start. You see some logs. 54 00:01:57,990 --> 00:01:59,760 For example this one, 'WordPress not 55 00:01:59,760 --> 00:02:02,040 found in '/var/www/html - 56 00:02:02,040 --> 00:02:05,160 copying now...'. But finally, we see in my 57 00:02:05,160 --> 00:02:07,140 case, actually, I see this error 58 00:02:07,290 --> 00:02:09,270 'caught SIGWINCH shutting down 59 00:02:09,300 --> 00:02:11,610 gracefully'. And I am actually back 60 00:02:11,610 --> 00:02:13,259 to terminal. And it seems that 61 00:02:13,289 --> 00:02:15,120 there are no containers currently 62 00:02:15,120 --> 00:02:17,460 running. Yes, that is the case. And 63 00:02:17,490 --> 00:02:19,620 basically, let me try to relaunch 64 00:02:19,650 --> 00:02:21,570 this container. Probably something 65 00:02:21,570 --> 00:02:23,520 went wrong during startup. Let me 66 00:02:23,520 --> 00:02:25,290 clear terminal and run container 67 00:02:25,290 --> 00:02:27,000 using 'docker run' command; and here 68 00:02:27,000 --> 00:02:30,030 will be 'wordpress'. Let's run it 69 00:02:30,030 --> 00:02:33,120 again. And it seems that now 70 00:02:33,120 --> 00:02:35,850 WordPress is run. Let's open up a 71 00:02:35,850 --> 00:02:38,520 new tab, 'docker ps'. And yes, I see 72 00:02:38,520 --> 00:02:40,350 that this container is now running. 73 00:02:40,530 --> 00:02:42,240 Here is the IMAGE that was used for 74 00:02:42,240 --> 00:02:44,040 launch of this container. Here is 75 00:02:44,040 --> 00:02:45,660 CONTAINER ID. Here is the random 76 00:02:45,660 --> 00:02:47,520 NAME for this container. And also 77 00:02:47,520 --> 00:02:49,560 you see that this container listens 78 00:02:49,590 --> 00:02:52,410 at Port 80 over TCP. And that's 79 00:02:52,410 --> 00:02:53,820 basically reasonable because 80 00:02:53,820 --> 00:02:56,220 WordPress uses Apache web server, 81 00:02:56,370 --> 00:02:58,080 and you are able to connect to 82 00:02:58,080 --> 00:03:00,840 WordPress over HTTP port 80. You're 83 00:03:00,840 --> 00:03:02,820 also able to set up HTTPS port if 84 00:03:02,820 --> 00:03:04,470 you want to, but default port is 85 00:03:04,500 --> 00:03:06,840 80. Also you see the COMMAND 86 00:03:06,870 --> 00:03:09,240 that was executed here is 'docker- 87 00:03:09,270 --> 00:03:12,540 entrypoint.sh'. I have explained you 88 00:03:12,570 --> 00:03:14,490 such approach in creation of new 89 00:03:14,490 --> 00:03:16,320 containers in previous section 90 00:03:16,320 --> 00:03:18,000 where we have talked about mongo 91 00:03:18,000 --> 00:03:19,920 containers. Again, in such case, 92 00:03:20,070 --> 00:03:22,020 instead of just single command, 93 00:03:22,260 --> 00:03:24,420 single script is executed, 'docker- 94 00:03:24,420 --> 00:03:27,090 entrypoint.sh' script. Great. 95 00:03:27,150 --> 00:03:28,950 Now we are not able to connect to 96 00:03:28,950 --> 00:03:30,660 this container over port 80, 97 00:03:30,690 --> 00:03:32,340 because we have not created port 98 00:03:32,340 --> 00:03:34,560 mapping. We have used simply command 99 00:03:34,740 --> 00:03:37,020 'docker run wordpress'. Actually, I 100 00:03:37,020 --> 00:03:38,700 see that this container was again 101 00:03:38,700 --> 00:03:41,640 stopped after some time. And if I 102 00:03:41,640 --> 00:03:43,680 will check it here, I'll see 103 00:03:43,680 --> 00:03:45,960 nothing here. Let me actually try 104 00:03:45,990 --> 00:03:47,820 to run this container probably with 105 00:03:47,850 --> 00:03:50,310 option '-d' in background and 106 00:03:50,310 --> 00:03:52,110 with port mapping. So let's use 107 00:03:52,110 --> 00:03:54,870 'docker run -d' in background; 108 00:03:55,050 --> 00:03:56,760 and here will be port mapping; and 109 00:03:56,760 --> 00:03:59,730 let's use external port 8080; and 110 00:03:59,730 --> 00:04:01,950 internal port will be 80, that you 111 00:04:01,950 --> 00:04:03,780 see actually here in this output. 112 00:04:04,050 --> 00:04:06,420 So let's try to start WordPress 113 00:04:06,420 --> 00:04:10,110 like so. Enter. Docker CONTAINER ID, 114 00:04:10,140 --> 00:04:11,940 here it is. Let's have a look at 115 00:04:11,970 --> 00:04:14,160 the containers now, 'docker ps'. 116 00:04:15,240 --> 00:04:17,339 And it seems that now container is 117 00:04:17,370 --> 00:04:19,769 running. Wonderful. Now let's go to 118 00:04:19,769 --> 00:04:21,660 the web browser and try to open 119 00:04:21,660 --> 00:04:24,000 session to port 8080. Again, you're 120 00:04:24,000 --> 00:04:26,339 able to use any local IP address of 121 00:04:26,370 --> 00:04:28,980 your computer, either localhost or 122 00:04:28,980 --> 00:04:32,580 127.0.0.1 or any other IP address 123 00:04:32,610 --> 00:04:34,890 assigned to any of your interfaces. 124 00:04:35,100 --> 00:04:37,050 So let's go to Google Chrome and 125 00:04:37,080 --> 00:04:40,620 type here localhost:8080. 126 00:04:42,660 --> 00:04:44,700 And we see WordPress setup 127 00:04:44,700 --> 00:04:46,740 configuration. And let's choose 128 00:04:46,770 --> 00:04:48,990 English here. Let's actually 129 00:04:48,990 --> 00:04:51,690 make it a bit smaller like this, and 130 00:04:51,840 --> 00:04:53,790 click here 'Continue'. We're 131 00:04:53,790 --> 00:04:55,980 actually able now to perform 132 00:04:56,010 --> 00:04:58,110 initial configuration of WordPress 133 00:04:58,380 --> 00:04:59,970 and we will need to specify 134 00:05:00,000 --> 00:05:02,130 Database name, Database username, 135 00:05:02,160 --> 00:05:03,840 Database password, and Database 136 00:05:03,840 --> 00:05:06,930 host. Let's click, 'Let's go!', and see 137 00:05:06,960 --> 00:05:09,000 what will happen. And here we are 138 00:05:09,000 --> 00:05:11,100 prompted to setup database 139 00:05:11,100 --> 00:05:13,560 connection including Database Host. 140 00:05:14,160 --> 00:05:15,960 Notice that here by default it is 141 00:05:15,960 --> 00:05:18,810 set to 'localhost'. Let's try to 142 00:05:18,810 --> 00:05:22,440 'Submit', and see what will happen. 'Error 143 00:05:22,470 --> 00:05:24,300 establishing a database connection'; 144 00:05:24,900 --> 00:05:26,760 and that means that there is no 145 00:05:26,790 --> 00:05:28,440 database at the moment; and we are 146 00:05:28,440 --> 00:05:30,150 not able to perform initial 147 00:05:30,150 --> 00:05:33,480 configuration of WordPress. MySQL 148 00:05:33,480 --> 00:05:36,030 database is absent by default out 149 00:05:36,030 --> 00:05:37,710 of the box in this 'wordpress' 150 00:05:37,710 --> 00:05:40,290 container. It has Apache web server 151 00:05:40,350 --> 00:05:42,780 but it doesn't have MySQL database. 152 00:05:43,170 --> 00:05:45,390 And you need to create a MySQL 153 00:05:45,390 --> 00:05:48,060 database somewhere else. And of 154 00:05:48,060 --> 00:05:49,380 course, you're able to create 155 00:05:49,410 --> 00:05:51,030 additional container and 156 00:05:51,030 --> 00:05:52,860 connect two containers - 'wordpress' 157 00:05:52,860 --> 00:05:55,830 container and 'mysql' container. And 158 00:05:55,830 --> 00:05:57,870 let's try to launch 'mysql' 159 00:05:57,870 --> 00:06:00,300 container next. I'll see you after the small 160 00:06:00,300 --> 00:06:01,300 pause. Bye-Bye. 161 00:06:01,300 --> 00:06:03,648 [no audio]