1
00:00:00,000 --> 00:00:09,440
In this video, you'll learn about Compose.

2
00:00:09,440 --> 00:00:10,440
So what is Compose?

3
00:00:10,440 --> 00:00:17,040
Well, Docker Compose and Popman Compose are used to run simple microservice-based applications

4
00:00:17,040 --> 00:00:18,840
based on a Compose file.

5
00:00:18,840 --> 00:00:23,200
And a Compose file is a complete definition of what you want to use.

6
00:00:23,200 --> 00:00:28,900
Now to use it, all the components of the containerized application are defined in this Compose file.

7
00:00:28,900 --> 00:00:32,220
And the docker-compose command is used to manage the application state.

8
00:00:32,220 --> 00:00:34,459
Let me show you.

9
00:00:34,459 --> 00:00:36,419
So I need to do a couple of things.

10
00:00:36,419 --> 00:00:42,980
First, I need sudo apt install docker-compose.

11
00:00:42,980 --> 00:00:45,900
It's a separate installation, as you can see.

12
00:00:45,900 --> 00:00:47,259
Then I need my Compose file.

13
00:00:47,259 --> 00:00:51,320
Well, I'm going to borrow it from a Git repository.

14
00:00:51,320 --> 00:00:55,619
So that's a Git repository I'm using for my containers course.

15
00:00:55,619 --> 00:01:03,320
GitHub.com slash Sander van Vugt slash containers should give access to it.

16
00:01:03,320 --> 00:01:06,440
Oh, forgetting git clone.

17
00:01:06,440 --> 00:01:09,040
Of course, that's the right command, git clone.

18
00:01:09,040 --> 00:01:16,639
So now when I go in this containers directory, we can see that there is a directory with

19
00:01:16,639 --> 00:01:20,180
the name WordPress MySQL.

20
00:01:20,180 --> 00:01:22,559
So what is in WordPress MySQL?

21
00:01:22,559 --> 00:01:25,199
There is a docker-compose.yaml.

22
00:01:25,779 --> 00:01:30,820
Docker-compose is using YAML files, and here you can see what it is doing.

23
00:01:30,820 --> 00:01:39,260
Okay, I really rather use Vim, but let's just go for docker-compose.yaml in nano.

24
00:01:39,260 --> 00:01:41,540
After all, editor is an editor.

25
00:01:41,540 --> 00:01:42,540
So what do we see?

26
00:01:42,540 --> 00:01:43,620
We see a version.

27
00:01:43,620 --> 00:01:45,940
We see that it defines a service.

28
00:01:45,940 --> 00:01:49,779
And every service is using a specific container image.

29
00:01:49,779 --> 00:01:54,419
And the nice thing about this Compose file is that you can provide information on how

30
00:01:54,639 --> 00:01:56,360
the image should be started.

31
00:01:56,360 --> 00:01:58,000
So we define a volume.

32
00:01:58,000 --> 00:02:00,720
We define some environment variables.

33
00:02:00,720 --> 00:02:05,959
We define some ports, and that is all that you are going to need.

34
00:02:05,959 --> 00:02:10,880
And the next thing is docker-compose up, and that will bring it up.

35
00:02:10,880 --> 00:02:16,360
And here you can see that the container is trying to get up.

36
00:02:16,360 --> 00:02:18,119
And oh boy, this doesn't work.

37
00:02:18,119 --> 00:02:19,520
Now, can we fix it?

38
00:02:19,520 --> 00:02:21,600
I think we can fix it.

39
00:02:21,600 --> 00:02:23,960
The problem here is an interesting problem.

40
00:02:24,000 --> 00:02:29,220
We talked about this before, and the problem is that it's telling me that it doesn't find

41
00:02:29,220 --> 00:02:36,020
a matching manifest for Linux ARM64 V8 in the manifest for WordPress.

42
00:02:36,020 --> 00:02:37,020
Now what is the case?

43
00:02:37,020 --> 00:02:45,660
The case is that I'm referring to MySQL 5.7, and that seems to be doing all right.

44
00:02:45,660 --> 00:02:50,940
Let me make that latest, and WordPress latest, well, apparently there is no ARM image.

45
00:02:50,940 --> 00:02:51,940
So you know what?

46
00:02:51,940 --> 00:02:58,559
I'm going to change that to nginx, colon, latest, because really this is not about getting

47
00:02:58,559 --> 00:03:01,720
it all to work and getting the perfect microservice.

48
00:03:01,720 --> 00:03:05,580
We want to understand what docker-compose is all about, right?

49
00:03:05,580 --> 00:03:11,119
So writing my changes, and then I'm doing my docker-compose up, and this time hopefully

50
00:03:11,119 --> 00:03:14,000
it is going better.

51
00:03:14,000 --> 00:03:24,160
Well, almost, there's a small typo in the name of the image.

52
00:03:24,160 --> 00:03:28,520
And there you can see it starts pulling the database image, and once it is done doing

53
00:03:28,520 --> 00:03:35,800
so, it will start pulling the nginx image, and the result will be a complete microservice

54
00:03:35,800 --> 00:03:39,039
application managed by docker-compose.

55
00:03:39,039 --> 00:03:43,800
I didn't do it the nice way because I didn't run it in the detached mode, and that is why

56
00:03:43,800 --> 00:03:47,800
we are looking at the screen right now.

57
00:03:47,800 --> 00:03:51,080
Control-C is an easy way to get out of there, and it will stop it.

58
00:03:51,080 --> 00:03:53,000
That's what you need to know about docker-compose.

