1
00:00:02,290 --> 00:00:04,730
So what is Docker Compose?

2
00:00:04,730 --> 00:00:07,010
It's really easy to understand in the end.

3
00:00:07,010 --> 00:00:11,400
Docker Compose is a tool that allows you to replace

4
00:00:11,400 --> 00:00:14,660
Docker build and Docker run commands

5
00:00:14,660 --> 00:00:16,800
and they're not just one Docker build

6
00:00:16,800 --> 00:00:18,510
and one Docker run command,

7
00:00:18,510 --> 00:00:21,130
but potentially multiple Docker build

8
00:00:21,130 --> 00:00:26,030
and Docker run commands with just one configuration file

9
00:00:26,030 --> 00:00:29,300
and then a set of orchestration commands

10
00:00:29,300 --> 00:00:33,890
to start all those services, all these containers at once

11
00:00:33,890 --> 00:00:37,430
and build all necessary images, if it should be required

12
00:00:37,430 --> 00:00:40,680
and you then also can use one command to stop everything

13
00:00:40,680 --> 00:00:44,060
and bring everything down and that will be great

14
00:00:44,060 --> 00:00:47,220
because whilst you can, of course already

15
00:00:47,220 --> 00:00:51,370
store Docker commands in any text file of your choice,

16
00:00:51,370 --> 00:00:54,240
and then just copy and paste them into your terminal,

17
00:00:54,240 --> 00:00:56,880
whilst you can already do that of course,

18
00:00:56,880 --> 00:00:59,090
this is not super convenient.

19
00:00:59,090 --> 00:01:03,490
And with Docker Compose, that will be much more convenient

20
00:01:04,930 --> 00:01:07,040
because with Docker Compose, you will have

21
00:01:07,040 --> 00:01:11,540
one configuration file using a clearly defined language

22
00:01:11,540 --> 00:01:13,400
which you can share with anyone

23
00:01:13,400 --> 00:01:17,410
and then it's just one command, no command copy and pasting

24
00:01:17,410 --> 00:01:21,270
just one command which will leverage this configuration file

25
00:01:21,270 --> 00:01:23,940
and which will then bring up or bring down

26
00:01:23,940 --> 00:01:27,290
your entire multicontainer application.

27
00:01:27,290 --> 00:01:29,150
Of course, just as a side note,

28
00:01:29,150 --> 00:01:30,910
you can also use Docker Compose

29
00:01:30,910 --> 00:01:32,980
in a single container application,

30
00:01:32,980 --> 00:01:36,630
it just shines the most if you have multiple containers

31
00:01:36,630 --> 00:01:40,050
because there, you can simply save a lot of extra commands

32
00:01:40,050 --> 00:01:42,150
and therefore time.

33
00:01:42,150 --> 00:01:45,080
I also briefly wanna highlight what Docker Compose

34
00:01:45,080 --> 00:01:48,410
is not though just to make this also clear.

35
00:01:48,410 --> 00:01:51,580
Docker Compose will not replace Docker files

36
00:01:51,580 --> 00:01:53,360
for custom images.

37
00:01:53,360 --> 00:01:55,350
You will see this in this module,

38
00:01:55,350 --> 00:01:58,730
Docker Compose works together with Docker files.

39
00:01:58,730 --> 00:02:01,230
It does not replace them.

40
00:02:01,230 --> 00:02:06,020
Docker Compose also does not replace images or containers.

41
00:02:06,020 --> 00:02:08,310
It just makes working with them easier,

42
00:02:08,310 --> 00:02:11,620
it makes launching containers ways easier

43
00:02:11,620 --> 00:02:15,410
and also important, Docker Compose is not suited

44
00:02:15,410 --> 00:02:18,690
for managing multiple containers on different hosts.

45
00:02:18,690 --> 00:02:21,930
At least that's not its primary strength.

46
00:02:21,930 --> 00:02:24,640
Docker Compose is really great for managing

47
00:02:24,640 --> 00:02:27,820
multiple containers on one and the same host

48
00:02:27,820 --> 00:02:30,950
and we'll talk about deploying containers to single

49
00:02:30,950 --> 00:02:33,840
and multiple hosts in the deployment section.

50
00:02:33,840 --> 00:02:35,670
For the moment we're running everything on

51
00:02:35,670 --> 00:02:38,160
our hosting machine, which is just one machine

52
00:02:38,160 --> 00:02:40,910
and therefore one host and therefore at the moment,

53
00:02:40,910 --> 00:02:43,650
Docker Compose is perfect and in general,

54
00:02:43,650 --> 00:02:47,530
it's a super powerful Docker tool, which you will use a lot

55
00:02:47,530 --> 00:02:51,350
in reality for development, but also for things

56
00:02:51,350 --> 00:02:53,540
beyond development, as you will learn

57
00:02:53,540 --> 00:02:55,090
throughout this course.

58
00:02:55,090 --> 00:02:58,170
Okay, so Docker Compose sounds quite interesting,

59
00:02:58,170 --> 00:03:00,260
how do we get with it?

60
00:03:00,260 --> 00:03:04,420
You always start by writing a Docker Compose file.

61
00:03:04,420 --> 00:03:06,670
Unlike Docker without compose,

62
00:03:06,670 --> 00:03:10,670
it's not primarily about executing commands in the terminal.

63
00:03:10,670 --> 00:03:13,100
Instead the idea is that you can save time there

64
00:03:13,100 --> 00:03:15,390
and therefore you put a lot of configuration

65
00:03:15,390 --> 00:03:17,850
into this Docker Compose file.

66
00:03:17,850 --> 00:03:19,320
And in this file,

67
00:03:19,320 --> 00:03:22,510
you need just define a couple of core things,

68
00:03:22,510 --> 00:03:25,220
a couple of core components that make up

69
00:03:25,220 --> 00:03:27,273
your multicontainer application.

70
00:03:28,410 --> 00:03:31,760
The heart and most important element

71
00:03:31,760 --> 00:03:34,240
or thing you can define in a compose file

72
00:03:34,240 --> 00:03:36,940
and you must define in a compose file

73
00:03:36,940 --> 00:03:39,580
are the so-called services which in the end

74
00:03:39,580 --> 00:03:41,770
can be translated with containers

75
00:03:41,770 --> 00:03:45,130
that make up your multicontainer application.

76
00:03:45,130 --> 00:03:49,180
But then below every service you can configure that service.

77
00:03:49,180 --> 00:03:53,120
And when I say service here, I really just mean container.

78
00:03:53,120 --> 00:03:55,970
You can define which port should be published,

79
00:03:55,970 --> 00:03:58,900
which environment variables this container might need.

80
00:03:58,900 --> 00:04:01,470
You can define volumes that should be assigned

81
00:04:01,470 --> 00:04:02,530
to this container.

82
00:04:02,530 --> 00:04:04,170
You can assign networks

83
00:04:04,170 --> 00:04:07,300
and you can do basically everything you can do with

84
00:04:07,300 --> 00:04:10,510
Docker command in the terminal otherwise,

85
00:04:10,510 --> 00:04:12,280
because the idea really is

86
00:04:12,280 --> 00:04:15,160
that we replace running these Docker commands

87
00:04:15,160 --> 00:04:18,610
in the terminal, that is the idea of compose.

88
00:04:18,610 --> 00:04:21,480
And therefore I'd say enough of the theory,

89
00:04:21,480 --> 00:04:25,460
let's get started and let's simply work on that project

90
00:04:25,460 --> 00:04:28,810
we built in the last module and let's use compose

91
00:04:28,810 --> 00:04:31,343
instead of running all these individual commands.

