1 00:00:00,000 --> 00:00:04,200 [Intro Music] 2 00:00:04,259 --> 00:00:05,969 Alright, as usually I hope that 3 00:00:05,999 --> 00:00:08,129 you solved this challenge yourself, 4 00:00:08,129 --> 00:00:09,899 and you were able to create two 5 00:00:09,899 --> 00:00:12,731 containers redis and redis-commander 6 00:00:12,731 --> 00:00:14,729 in separate custom bridge 7 00:00:14,729 --> 00:00:16,889 network called 'redis'; and you were 8 00:00:16,889 --> 00:00:18,989 able to connect from redis-commander 9 00:00:19,019 --> 00:00:20,579 to redis using graphical user 10 00:00:20,579 --> 00:00:22,679 interface. Now, let me do that 11 00:00:22,919 --> 00:00:25,019 together with you. And first of 12 00:00:25,019 --> 00:00:27,179 all, let me go to VS Code. and let 13 00:00:27,179 --> 00:00:29,759 me create here a new folder inside 14 00:00:29,759 --> 00:00:31,679 of the containers folder, and that 15 00:00:31,679 --> 00:00:34,649 folder name will be 'redis', like so. 16 00:00:35,009 --> 00:00:37,019 And here inside let me create a new 17 00:00:37,019 --> 00:00:40,769 file commands.txt, similarly 18 00:00:40,769 --> 00:00:42,809 as we did for previous cases, when 19 00:00:42,809 --> 00:00:44,399 we have launched multiple 20 00:00:44,399 --> 00:00:46,859 containers in the same network. And 21 00:00:46,859 --> 00:00:48,809 here first command will be 22 00:00:49,109 --> 00:00:54,359 CREATE NEW CUSTOM NETWORK, 'docker 23 00:00:54,629 --> 00:00:57,449 network create', and name of the 24 00:00:57,449 --> 00:01:01,229 network will be 'redis'. Next, LAUNCH 25 00:01:01,409 --> 00:01:05,519 REDIS CONTAINER, and let me launch 26 00:01:05,519 --> 00:01:08,129 it in this custom 'redis' network, 27 00:01:08,159 --> 00:01:09,959 and I'll give it a custom name 28 00:01:09,989 --> 00:01:13,799 'redis', 'docker run \', 29 00:01:14,219 --> 00:01:18,989 '--name redis'. Next comes 30 00:01:18,989 --> 00:01:21,029 network, '--network 31 00:01:21,599 --> 00:01:25,289 redis'. Also, let me run this 32 00:01:25,289 --> 00:01:27,479 container in background, and the 33 00:01:27,539 --> 00:01:30,239 image name will be 'redis'. And 34 00:01:30,239 --> 00:01:31,919 that's probably all what I need for 35 00:01:31,919 --> 00:01:33,569 'redis' container. But if I will 36 00:01:33,569 --> 00:01:35,429 require something else, I'll edit 37 00:01:35,429 --> 00:01:37,949 later. Great. Let's next 38 00:01:37,949 --> 00:01:40,300 launch redis-commander, 39 00:01:40,300 --> 00:01:46,000 LAUNCH REDIS-COMMANDER CONTAINER, and 40 00:01:46,079 --> 00:01:48,989 I'll launch it using same command 41 00:01:49,019 --> 00:01:52,319 'docker run \'. Let's give it 42 00:01:52,319 --> 00:01:55,349 name, '--name redis- 43 00:01:55,649 --> 00:01:58,979 commander', like this. Next comes 44 00:01:58,979 --> 00:02:01,079 network, we will create this 45 00:02:01,079 --> 00:02:02,819 container in the same redis 46 00:02:02,819 --> 00:02:07,049 network, '--network redis \', 47 00:02:07,379 --> 00:02:09,479 I'll also run this container in 48 00:02:09,479 --> 00:02:11,519 background. And here will be the 49 00:02:11,519 --> 00:02:14,249 name of the image. Let me go to 50 00:02:14,249 --> 00:02:16,829 Google Chrome and click on this 51 00:02:16,859 --> 00:02:19,199 image, 'rediscommander\ 52 00:02:19,229 --> 00:02:20,879 redis-commander', 53 00:02:20,910 --> 00:02:23,430 let me copy this name from here, and 54 00:02:23,460 --> 00:02:26,430 paste here, like so. Also, let 55 00:02:26,430 --> 00:02:29,070 me scroll down here, and somewhere 56 00:02:29,070 --> 00:02:30,780 in those settings, you may find 57 00:02:30,810 --> 00:02:33,960 default port, it is 8081. But of 58 00:02:33,960 --> 00:02:35,820 course, if you need you are able to 59 00:02:35,850 --> 00:02:38,940 adjust this port number. Let me go 60 00:02:38,940 --> 00:02:41,460 back to VS Code, and here let me 61 00:02:41,490 --> 00:02:43,950 add the port mapping, '-p', 62 00:02:44,010 --> 00:02:46,740 and external port I'll use same as 63 00:02:46,740 --> 00:02:48,900 internal; 8081, and internal 64 00:02:48,900 --> 00:02:52,200 will be 8081, like this. But 65 00:02:52,230 --> 00:02:53,790 now let me quickly tell you a few 66 00:02:53,790 --> 00:02:55,410 words about redis-commander. 67 00:02:55,620 --> 00:02:57,960 Actually it is available as you see 68 00:02:57,960 --> 00:03:00,840 here as Docker Image, but it is also 69 00:03:00,840 --> 00:03:04,038 available as NPM package for Node.js, 70 00:03:04,038 --> 00:03:05,220 because actually redis- 71 00:03:05,220 --> 00:03:07,410 commander is written in Node.js, 72 00:03:07,440 --> 00:03:09,060 and you may read this information 73 00:03:09,090 --> 00:03:11,760 here, and you are able to install it 74 00:03:11,760 --> 00:03:14,340 either using npm or use 75 00:03:14,340 --> 00:03:16,860 container, here it is; and we are 76 00:03:16,860 --> 00:03:18,750 actually using it as a container. 77 00:03:19,050 --> 00:03:21,450 Let me scroll down here, and let me 78 00:03:21,450 --> 00:03:22,830 show you which environment 79 00:03:22,830 --> 00:03:25,020 variables we should use for this 80 00:03:25,020 --> 00:03:27,600 container. Here you see a set of 81 00:03:27,630 --> 00:03:29,160 environment variables, and here a 82 00:03:29,160 --> 00:03:31,290 set of additional environment 83 00:03:31,290 --> 00:03:33,120 variables like REDIS_PORT, 84 00:03:33,150 --> 00:03:35,700 REDIS_HOST; and now let's set 85 00:03:35,700 --> 00:03:37,680 only single environment variable, 86 00:03:37,740 --> 00:03:40,770 REDIS_HOST, and as a value, we will 87 00:03:40,770 --> 00:03:43,530 specify simply 'redis' as the name of 88 00:03:43,530 --> 00:03:46,140 the redis container. Alright, let 89 00:03:46,140 --> 00:03:47,700 me copy REDIS_HOST environment 90 00:03:47,700 --> 00:03:49,980 variable here, and go back to 91 00:03:49,980 --> 00:03:51,750 configuration of this container, 92 00:03:51,930 --> 00:03:53,730 and let me add environment variable 93 00:03:53,760 --> 00:03:56,940 '-e REDIS_HOST= 94 00:03:56,970 --> 00:04:00,120 redis', like this. And it seems that 95 00:04:00,150 --> 00:04:02,070 that's all what I will need in 96 00:04:02,070 --> 00:04:04,410 order to start this container. But 97 00:04:04,410 --> 00:04:06,240 again, I haven't done it before and 98 00:04:06,270 --> 00:04:08,010 if I miss something I'll add 99 00:04:08,010 --> 00:04:09,990 additional configuration parameters 100 00:04:09,990 --> 00:04:12,450 here later on. For now that's it. 101 00:04:12,780 --> 00:04:15,240 Let me save this, and let me copy 102 00:04:15,240 --> 00:04:17,310 first command, 'docker network create 103 00:04:17,310 --> 00:04:19,709 redis', and go to terminal in order 104 00:04:19,709 --> 00:04:21,899 to start those containers. All 105 00:04:21,899 --> 00:04:24,088 right, 'docker network create redis', 106 00:04:24,088 --> 00:04:26,610 network was created, next let's 107 00:04:26,640 --> 00:04:29,880 start redis container like this. 108 00:04:30,240 --> 00:04:32,910 Let me copy this command. Container 109 00:04:32,910 --> 00:04:35,370 was started. Let's go back to 110 00:04:35,400 --> 00:04:37,980 redis-commander. Let me copy this 111 00:04:37,980 --> 00:04:41,100 command, go back to terminal, and 112 00:04:41,130 --> 00:04:43,320 start redis-commander. Recap 113 00:04:43,320 --> 00:04:45,330 that we have not yet pulled redis- 114 00:04:45,330 --> 00:04:47,070 commander image and that's why now 115 00:04:47,100 --> 00:04:49,440 Docker is pulling it. Alright, 116 00:04:49,470 --> 00:04:51,420 Pull was completed, and it seems 117 00:04:51,420 --> 00:04:53,790 that both containers should be now 118 00:04:53,820 --> 00:04:55,710 up and running. Let me have a look 119 00:04:55,710 --> 00:04:58,380 at them, 'docker ps', and yes, there 120 00:04:58,380 --> 00:05:00,960 are two containers up. And now I 121 00:05:00,960 --> 00:05:03,510 could try access redis-commander 122 00:05:03,600 --> 00:05:05,640 graphical user interface from a 123 00:05:05,640 --> 00:05:08,190 local computer using port 8081 in 124 00:05:08,190 --> 00:05:10,590 web browser. Let me go there, and 125 00:05:10,590 --> 00:05:14,700 here type localhost:8081, like 126 00:05:14,700 --> 00:05:19,260 this. And I'm in, and here you 127 00:05:19,260 --> 00:05:21,780 actually see connection to Redis 128 00:05:21,780 --> 00:05:23,880 server. Let me make it a bit 129 00:05:23,910 --> 00:05:26,790 smaller like this, and let's try to 130 00:05:26,790 --> 00:05:28,560 add new key, click on this 131 00:05:28,560 --> 00:05:30,900 button, Add New Key', key will be, 132 00:05:30,900 --> 00:05:33,330 let's say, key2, and the value 133 00:05:33,330 --> 00:05:37,650 will be, 'Good day', like so. And 134 00:05:37,650 --> 00:05:41,430 here, let's click OK, Save 135 00:05:41,430 --> 00:05:43,410 actually, and it seems that new key 136 00:05:43,410 --> 00:05:45,270 was added. Let me verify that, 137 00:05:45,300 --> 00:05:48,120 you are able to expand this here, 138 00:05:48,150 --> 00:05:50,610 and I'll see key2 here on the 139 00:05:50,610 --> 00:05:52,920 list. Let me click on key2, and 140 00:05:52,950 --> 00:05:55,260 I'll get its value here. And that 141 00:05:55,260 --> 00:05:57,150 means that the redis-commander is 142 00:05:57,150 --> 00:05:59,460 working, and now it communicates 143 00:05:59,460 --> 00:06:01,650 correctly with Redis server. And 144 00:06:01,650 --> 00:06:03,540 notice that we have not specified 145 00:06:03,570 --> 00:06:05,775 any authentication parameters either 146 00:06:05,775 --> 00:06:08,130 for Redis server or for redis- 147 00:06:08,130 --> 00:06:10,050 commander; and we have simply looked 148 00:06:10,080 --> 00:06:12,540 into redis-commander without any 149 00:06:12,540 --> 00:06:14,550 username and password. But for the 150 00:06:14,550 --> 00:06:15,660 sake of this challenge that's 151 00:06:15,660 --> 00:06:18,720 pretty fine, and actually all what 152 00:06:18,720 --> 00:06:19,770 you need to do in the redis- 153 00:06:19,770 --> 00:06:21,690 commander container, you need to 154 00:06:21,690 --> 00:06:23,580 specify an environment variable 155 00:06:23,640 --> 00:06:26,100 called REDIS_HOST, and in our case, 156 00:06:26,130 --> 00:06:28,440 it is set to name of 'redis' 157 00:06:28,440 --> 00:06:30,660 container and recap that because 158 00:06:30,690 --> 00:06:32,520 those containers are running in a 159 00:06:32,520 --> 00:06:35,040 separate custom network, this name 160 00:06:35,070 --> 00:06:37,560 redis will be resolved by Docker 161 00:06:37,560 --> 00:06:39,900 Host to IP address of redis 162 00:06:39,900 --> 00:06:42,660 container, this container. That's all 163 00:06:42,660 --> 00:06:44,310 guys for this challenge. And now 164 00:06:44,310 --> 00:06:45,840 let me quickly stop those 165 00:06:45,840 --> 00:06:47,520 containers. I don't need them 166 00:06:47,550 --> 00:06:52,890 anymore. 'docker stop 47', 'docker 167 00:06:52,920 --> 00:06:58,020 stop ef', and 'docker container 168 00:06:58,680 --> 00:07:02,790 prune', Yes. All right. That's all 169 00:07:02,790 --> 00:07:04,410 guys for this lesson, and I'll see 170 00:07:04,410 --> 00:07:06,150 you next where we will explore 171 00:07:06,360 --> 00:07:08,490 another Docker Image. I'll see you 172 00:07:08,490 --> 00:07:09,400 next. Bye-Bye. 173 00:07:09,400 --> 00:07:11,936 [no audio]