1 00:00:00,300 --> 00:00:04,200 [Intro Music] 2 00:00:04,260 --> 00:00:06,060 Now there are two containers up and 3 00:00:06,060 --> 00:00:07,740 running. And we see here that 4 00:00:07,770 --> 00:00:09,390 'docker-compose' process is also 5 00:00:09,390 --> 00:00:11,670 running. And let's first interrupt 6 00:00:11,670 --> 00:00:12,870 this process by pressing key 7 00:00:12,870 --> 00:00:15,630 combination Ctrl+C like that. You 8 00:00:15,630 --> 00:00:17,370 see that two containers are now 9 00:00:17,370 --> 00:00:19,650 stopping, this one and this one. 10 00:00:19,890 --> 00:00:22,350 Containers were stopped. And if I 11 00:00:22,350 --> 00:00:24,480 enter 'docker ps' now, I will see 12 00:00:24,480 --> 00:00:26,040 empty output, because 13 00:00:26,040 --> 00:00:27,810 'docker-compose' has stopped both 14 00:00:27,810 --> 00:00:30,570 containers. Now let's try to rerun 15 00:00:30,600 --> 00:00:32,130 both containers using the same 16 00:00:32,130 --> 00:00:33,960 command as before 'docker-compose 17 00:00:33,990 --> 00:00:35,910 up', but now let's run them in 18 00:00:35,910 --> 00:00:37,890 background. And first let's have a 19 00:00:37,890 --> 00:00:39,570 look at all options that you have 20 00:00:39,630 --> 00:00:42,300 in 'docker-compose up' command. For 21 00:00:42,300 --> 00:00:43,890 that, please type 'docker-compose 22 00:00:43,950 --> 00:00:46,980 up --help'. Here you'll find a list 23 00:00:46,980 --> 00:00:49,050 of options. In this options list, 24 00:00:49,080 --> 00:00:51,060 you could find option '--build' 25 00:00:51,240 --> 00:00:53,310 that allows you to rebuild all 26 00:00:53,340 --> 00:00:54,480 images defined in the 27 00:00:54,480 --> 00:00:56,880 'docker-compose' file. And also at 28 00:00:56,880 --> 00:00:58,740 the beginning of this options list, 29 00:00:58,830 --> 00:01:00,390 you should find option that is 30 00:01:00,390 --> 00:01:04,349 called '-d', or '--detach'; and 31 00:01:04,379 --> 00:01:06,239 this will run all containers 32 00:01:06,269 --> 00:01:07,830 defined in the 'docker-compose' 33 00:01:07,830 --> 00:01:10,440 file in detached mode, and that's 34 00:01:10,470 --> 00:01:12,720 what we will try right now. Let's 35 00:01:12,720 --> 00:01:13,830 clear terminal and type 36 00:01:13,860 --> 00:01:18,060 'docker-compose up -d', this stands 37 00:01:18,060 --> 00:01:20,220 for detached mode. Let's go ahead, 38 00:01:20,970 --> 00:01:22,800 Starting both containers, 39 00:01:23,160 --> 00:01:24,930 'images-gallery_api_1' and 40 00:01:24,960 --> 00:01:28,380 'images-gallery_frontend_1'. 'done' 41 00:01:29,100 --> 00:01:31,590 and 'done' here. Now, I returned to 42 00:01:31,590 --> 00:01:33,120 the command prompt, and I could 43 00:01:33,120 --> 00:01:35,130 continue doing other operations. 44 00:01:35,340 --> 00:01:37,020 Let's have a look at currently running 45 00:01:37,020 --> 00:01:39,960 containers, 'docker ps', and I see 46 00:01:39,990 --> 00:01:42,000 both containers that are up and 47 00:01:42,000 --> 00:01:45,000 running same as before, 'api', and 48 00:01:45,030 --> 00:01:48,030 'frontend' containers. Great. Let's 49 00:01:48,030 --> 00:01:49,860 now verify whether our application 50 00:01:49,860 --> 00:01:52,500 works as before. Refresh page here, 51 00:01:53,400 --> 00:01:56,160 search for something and they both 52 00:01:56,160 --> 00:01:59,100 result same as before. Great. Now 53 00:01:59,100 --> 00:02:01,080 let me show you how you're able to 54 00:02:01,080 --> 00:02:03,240 stop those containers by using 55 00:02:03,300 --> 00:02:05,190 'docker-compose down' command. 56 00:02:05,670 --> 00:02:07,140 Let's clear terminal and type 57 00:02:07,140 --> 00:02:10,440 'docker-compose down'. And it's 58 00:02:10,440 --> 00:02:11,940 important to mention that you need 59 00:02:11,940 --> 00:02:13,710 to run those commands like 60 00:02:13,740 --> 00:02:15,270 'docker-compose down' or 61 00:02:15,300 --> 00:02:17,310 'docker-compose up' in specific 62 00:02:17,310 --> 00:02:19,080 folder where there was 63 00:02:19,080 --> 00:02:21,390 corresponding 'docker-compose.yml' 64 00:02:21,390 --> 00:02:23,610 file. Okay, let's bring down both 65 00:02:23,610 --> 00:02:25,980 containers. Both containers are 66 00:02:25,980 --> 00:02:27,210 being stopped at the moment. 67 00:02:27,960 --> 00:02:30,390 Stopped. Also those containers were 68 00:02:30,390 --> 00:02:32,970 removed. And also network that was 69 00:02:32,970 --> 00:02:34,560 created specifically for 70 00:02:34,560 --> 00:02:35,760 communication between those 71 00:02:35,760 --> 00:02:37,740 containers was removed as well. 72 00:02:37,830 --> 00:02:38,820 Network Name is 73 00:02:38,850 --> 00:02:40,980 'images-gallery_default'. Let's 74 00:02:40,980 --> 00:02:42,810 start those containers back again, 75 00:02:43,140 --> 00:02:46,410 'docker-compose up -d', detach 76 00:02:46,410 --> 00:02:51,000 mode. Creating network. Creating 77 00:02:51,000 --> 00:02:53,640 containers. Notice that we don't 78 00:02:53,670 --> 00:02:55,950 build new images because images are 79 00:02:55,950 --> 00:02:59,430 already built. 'done' here; and 'done' 80 00:02:59,430 --> 00:03:02,370 here. And containers are now again 81 00:03:02,400 --> 00:03:05,190 up and running. Great. Now let's 82 00:03:05,190 --> 00:03:06,480 commit the changes made in 83 00:03:06,510 --> 00:03:08,010 'docker-compose' file. It is 84 00:03:08,010 --> 00:03:10,110 actually its initial version. Let's 85 00:03:10,110 --> 00:03:12,120 go to source control, and here our 86 00:03:12,120 --> 00:03:13,890 commit message will be 'Initial 87 00:03:14,010 --> 00:03:17,760 version of the docker-compose' like 88 00:03:17,760 --> 00:03:20,340 that. Let's commit changes, Changes 89 00:03:20,340 --> 00:03:22,050 committed. And now let's proceed 90 00:03:22,080 --> 00:03:24,150 and next I'll explain to you how to 91 00:03:24,150 --> 00:03:27,090 map volumes to the containers and 92 00:03:27,090 --> 00:03:29,040 you'll understand why we actually 93 00:03:29,040 --> 00:03:31,080 need to do that. I'll see you guys 94 00:03:31,100 --> 00:03:32,100 just in a bit. 95 00:03:32,100 --> 00:03:33,500 [no audio]