In this video, you'll learn about Compose.
So what is Compose?
Well, Docker Compose and Popman Compose are used to run simple microservice-based applications
based on a Compose file.
And a Compose file is a complete definition of what you want to use.
Now to use it, all the components of the containerized application are defined in this Compose file.
And the docker-compose command is used to manage the application state.
Let me show you.
So I need to do a couple of things.
First, I need sudo apt install docker-compose.
It's a separate installation, as you can see.
Then I need my Compose file.
Well, I'm going to borrow it from a Git repository.
So that's a Git repository I'm using for my containers course.
GitHub.com slash Sander van Vugt slash containers should give access to it.
Oh, forgetting git clone.
Of course, that's the right command, git clone.
So now when I go in this containers directory, we can see that there is a directory with
the name WordPress MySQL.
So what is in WordPress MySQL?
There is a docker-compose.yaml.
Docker-compose is using YAML files, and here you can see what it is doing.
Okay, I really rather use Vim, but let's just go for docker-compose.yaml in nano.
After all, editor is an editor.
So what do we see?
We see a version.
We see that it defines a service.
And every service is using a specific container image.
And the nice thing about this Compose file is that you can provide information on how
the image should be started.
So we define a volume.
We define some environment variables.
We define some ports, and that is all that you are going to need.
And the next thing is docker-compose up, and that will bring it up.
And here you can see that the container is trying to get up.
And oh boy, this doesn't work.
Now, can we fix it?
I think we can fix it.
The problem here is an interesting problem.
We talked about this before, and the problem is that it's telling me that it doesn't find
a matching manifest for Linux ARM64 V8 in the manifest for WordPress.
Now what is the case?
The case is that I'm referring to MySQL 5.7, and that seems to be doing all right.
Let me make that latest, and WordPress latest, well, apparently there is no ARM image.
So you know what?
I'm going to change that to nginx, colon, latest, because really this is not about getting
it all to work and getting the perfect microservice.
We want to understand what docker-compose is all about, right?
So writing my changes, and then I'm doing my docker-compose up, and this time hopefully
it is going better.
Well, almost, there's a small typo in the name of the image.
And there you can see it starts pulling the database image, and once it is done doing
so, it will start pulling the nginx image, and the result will be a complete microservice
application managed by docker-compose.
I didn't do it the nice way because I didn't run it in the detached mode, and that is why
we are looking at the screen right now.
Control-C is an easy way to get out of there, and it will stop it.
That's what you need to know about docker-compose.