1 00:00:00,000 --> 00:00:04,000 [Intro Music] 2 00:00:04,000 --> 00:00:06,000 So now you understand what is 3 00:00:06,000 --> 00:00:07,890 environment variable, and also you 4 00:00:07,890 --> 00:00:09,750 know how to verify which 5 00:00:09,780 --> 00:00:11,400 environment variables are set in 6 00:00:11,400 --> 00:00:14,040 specific container. Let's now exit 7 00:00:14,040 --> 00:00:15,990 from all those containers and let 8 00:00:15,990 --> 00:00:18,330 me basically actually stop them and 9 00:00:18,360 --> 00:00:21,390 remove. Let me exit from busybox 10 00:00:21,390 --> 00:00:24,330 here, and here. Let's list containers, 11 00:00:24,360 --> 00:00:26,310 'docker ps'. There are no containers 12 00:00:26,310 --> 00:00:28,440 running. 'docker ps -a', here are 13 00:00:28,440 --> 00:00:30,390 stopped containers. And let's use 14 00:00:30,420 --> 00:00:33,479 'docker container prune' in order to 15 00:00:33,479 --> 00:00:36,480 remove all containers. Yes. Great. 16 00:00:36,690 --> 00:00:38,700 Let's now proceed. And now let's 17 00:00:38,730 --> 00:00:41,730 try to create mysql container, and 18 00:00:41,730 --> 00:00:43,470 see whether it will be started or 19 00:00:43,470 --> 00:00:45,960 not. Let's use 'docker run' command, 20 00:00:46,140 --> 00:00:51,570 'docker run mysql', finding image 21 00:00:51,570 --> 00:00:54,600 'mysql:latest', unable to find 22 00:00:54,600 --> 00:00:57,000 locally. As usually pulling from 23 00:00:57,000 --> 00:00:59,550 Docker Hub, extracting different 24 00:00:59,550 --> 00:01:01,020 layers, and you see that one of the 25 00:01:01,020 --> 00:01:02,850 layers already exists locally, 26 00:01:03,090 --> 00:01:04,500 there is no need to pull it if it 27 00:01:04,500 --> 00:01:06,239 already exists. Let's wait a bit. 28 00:01:06,780 --> 00:01:09,240 All right image was downloaded. And 29 00:01:09,240 --> 00:01:12,100 here you see attempt to start MySQL 30 00:01:12,100 --> 00:01:14,100 server, Entrypoint script for 31 00:01:14,100 --> 00:01:16,770 MySQL Server 8.0.19 32 00:01:16,770 --> 00:01:19,200 started. And finally you'll see a 33 00:01:19,200 --> 00:01:21,480 message, 'You need to specify one of 34 00:01:21,480 --> 00:01:24,330 MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_ 35 00:01:24,330 --> 00:01:26,730 EMPTY_PASSWORD and MYSQL_RANDOM_ 36 00:01:26,760 --> 00:01:29,310 ROOT_PASSWORD'. And finally, this 37 00:01:29,310 --> 00:01:30,900 application was terminated 38 00:01:30,900 --> 00:01:32,760 actually, this container isn't running 39 00:01:32,790 --> 00:01:35,190 anymore. 'docker ps', there are no 40 00:01:35,220 --> 00:01:37,590 running containers. And that's what I 41 00:01:37,590 --> 00:01:39,480 have told you before, you're not 42 00:01:39,510 --> 00:01:42,240 able to start MySQL server out of 43 00:01:42,240 --> 00:01:44,730 the box without initial at least 44 00:01:44,730 --> 00:01:47,100 one environment variable. You need 45 00:01:47,100 --> 00:01:49,920 to set up either MYSQL_ROOT_PASSWORD, 46 00:01:49,950 --> 00:01:52,350 it's password for root user, or 47 00:01:52,380 --> 00:01:54,450 you're able to use another 48 00:01:54,450 --> 00:01:56,340 environment variable MYSQL_ALLOW_ 49 00:01:56,340 --> 00:01:58,320 EMPTY_PASSWORD, that will actually 50 00:01:58,350 --> 00:02:00,300 allow login without password 51 00:02:00,300 --> 00:02:02,700 for root user, that's not secure at 52 00:02:02,700 --> 00:02:06,060 all, or you're able to use MYSQL_ 53 00:02:06,090 --> 00:02:08,340 RANDOM_ROOT_PASSWORD option that 54 00:02:08,340 --> 00:02:10,500 will create a random password for 55 00:02:10,530 --> 00:02:13,410 root user. And now it's a good time 56 00:02:13,440 --> 00:02:16,500 to start MySQL using additional 57 00:02:16,500 --> 00:02:18,480 environment variable. And you are 58 00:02:18,480 --> 00:02:20,460 able to set environment variable 59 00:02:20,460 --> 00:02:22,380 for a specific container using 60 00:02:22,410 --> 00:02:25,140 additional options '-e'. Let's do 61 00:02:25,140 --> 00:02:27,180 that. And let's set this option, 62 00:02:27,180 --> 00:02:29,730 MYSQL_ROOT_PASSWORD. Let me copy 63 00:02:29,760 --> 00:02:31,320 this environment variable name, 64 00:02:31,440 --> 00:02:33,540 clear terminal, and again let's 65 00:02:33,540 --> 00:02:36,240 use 'docker run' command, I'll create 66 00:02:36,360 --> 00:02:38,640 a new container of course. And here 67 00:02:38,670 --> 00:02:40,290 let's use the '-e' option. 68 00:02:40,470 --> 00:02:42,099 Basically let me first use 69 00:02:42,099 --> 00:02:44,490 '--help' here and show you this 70 00:02:44,490 --> 00:02:46,650 option on the list. Let me scroll 71 00:02:46,680 --> 00:02:49,980 up and it will be somewhere here. 72 00:02:50,010 --> 00:02:53,700 Yes, '-e' or '--env list' : Set 73 00:02:53,730 --> 00:02:55,830 environment variables. And you are 74 00:02:55,830 --> 00:02:58,050 able to set multiple environment 75 00:02:58,050 --> 00:03:01,170 variables by using '-e' option 76 00:03:01,200 --> 00:03:03,630 multiple times. Great. Let's 77 00:03:03,630 --> 00:03:06,683 proceed. 'docker run -e'. 78 00:03:06,683 --> 00:03:08,730 Let's paste the copied 79 00:03:09,270 --> 00:03:11,280 environment variable name, MYSQL_ 80 00:03:11,310 --> 00:03:13,530 ROOT_PASSWORD, and here will be 81 00:03:13,530 --> 00:03:16,100 equal sign. And let's set it to 82 00:03:16,100 --> 00:03:19,700 'my-password' like so. Again, it is a 83 00:03:19,770 --> 00:03:21,960 password for root user. And 84 00:03:21,960 --> 00:03:23,820 afterwards, we are able to specify 85 00:03:23,850 --> 00:03:26,190 name of the image like so, 'mysql'; 86 00:03:26,610 --> 00:03:28,380 and let's now try to start this 87 00:03:28,380 --> 00:03:30,780 container with set environment 88 00:03:30,780 --> 00:03:35,490 variable MYSQL_ROOT_PASSWORD. And 89 00:03:35,490 --> 00:03:37,680 now you see bunch of messages that 90 00:03:37,710 --> 00:03:40,290 tell us that MySQL Server is 91 00:03:40,320 --> 00:03:42,750 basically starting and now it is 92 00:03:42,750 --> 00:03:44,820 actually running, and we are able 93 00:03:44,820 --> 00:03:46,650 to verify that. Let's open up a new 94 00:03:46,650 --> 00:03:49,410 tab and enter 'docker ps' here. And 95 00:03:49,410 --> 00:03:51,930 yes, mysql container is now up, 96 00:03:52,020 --> 00:03:54,090 here is CONTAINER ID, here is the 97 00:03:54,120 --> 00:03:55,890 IMAGE that was used, here is 98 00:03:55,890 --> 00:03:58,110 COMMAND that was executed, it's also 99 00:03:58,140 --> 00:04:00,780 this image uses entrypoint instead 100 00:04:00,780 --> 00:04:04,350 of cmd, 'docker-entry point.sh'. And 101 00:04:04,380 --> 00:04:06,810 also you see that this container 102 00:04:06,870 --> 00:04:12,135 listens at two ports 3306 and 33060, 103 00:04:12,135 --> 00:04:14,100 this one. Great. This is how 104 00:04:14,100 --> 00:04:16,980 we were able to start MySQL server. 105 00:04:17,459 --> 00:04:19,589 But now let's try to connect to the 106 00:04:19,589 --> 00:04:21,660 server. How we're able to do that? 107 00:04:21,930 --> 00:04:24,420 We're able to do that in CLI 108 00:04:24,420 --> 00:04:26,430 terminal, or we're able to use 109 00:04:26,459 --> 00:04:30,109 graphical interface called phpMyAdmin, 110 00:04:30,109 --> 00:04:31,560 and let me demonstrate you 111 00:04:31,560 --> 00:04:34,589 how we are able to launch phpMyAdmin 112 00:04:34,589 --> 00:04:36,270 and connect to this MySQL 113 00:04:36,270 --> 00:04:39,007 server next. I will see you next. Bye-Bye. 114 00:04:39,007 --> 00:04:41,258 [no audio]