So let's use compose here in this project
and you'll find this project attached
and it is the project we built
in the last course section.
So we have a backend
and we have a frontend
and we got the docker files
in the backend and frontend folders.
So did we there
also have these images prepared
because as I mentioned,
we'll need these docker files.
Docker compose will not replace them.
Now, how do we get started with docker compose then?
Well, in your project folder,
you create a docker-compose.yml or yamol file.
The extension can be free or four characters.
It's always a yamol file
and yamol is just a specific text format
where you use indentation
to express dependencies
between configuration options.
You'll see it in action here.
Now, in such a docker compose yamol file,
you describe your multi container environment,
your project setup,
and you always start by defining a version here.
Now you should get auto completion here, by the way,
since we installed the docker extension,
make sure you have
that Docker extension installed
in visual studio code
and with that you will get all the completion here,
which is very helpful.
So we specify a version here
and with version I don't mean a version
for our app or our file here.
Instead, we specify the version
of the docker compose specification we wanna use
and the version we defined here
has an effect on the features
we can use in this compose file
because the docker compose specification
and therefore the Syntex we have
to use in this docker compose file
is under active development
and may change over time.
So you can lock in a certain version up here
so the docker knows which features are
and are not available.
And therefore it's able
to execute your docker compose file correctly.
Now you can visit docs.docker.com/compose/composed-file.
And you will find a complete reference
of all the configuration options
you can set up in a composed file,
and you also find the different
compose specification versions,
which are available.
And obviously that will change over time.
I'm using 3.8 when I'm recording this,
there will be newer versions out
when you're viewing this most likely.
However, of course, a new version
does not mean that everything changed
maybe some tiny new features were added
and to be honest,
most of the features you can use
most of the configurations you can add
might not matter to your project.
And that's an evernote
I have about this site here.
It's a huge list,
a long list of configuration options
you can add in your docker compose yamol file
and you will not need all of them.
You will only need a small subset
for most applications
but of course,
in order to express any potential projects
that you might have,
you have a lot of configuration options here.
Now you can use this as a backup reference.
I just wanted to talk about these versions.
And so they offer at the moment
3.8 is the latest version I have available.
And I will specify this here
therefore, to inform docker
that this is the version does file uses
and to let docker know
which features I therefore want to use
and want to be able to use.
So that is the first thing we have to add, the version,
that next thing,
the next configuration we have to add here
is the services key
And by the way,
these key names of course
have to be typed correctly
because docker will look out for these keywords.
So this has to be version
and not Version like this
or VRS like this.
It has to be written exactly like that.
That's why it is auto-completion
with the docker extension helps.
So here we got services
and now services doesn't take a value like this.
Instead it has a couple of nested values.
So we enter a new line
and now the indentation here matters.
I did indent by two blanks here.
And this is important
because yamol uses indentation
to express dependencies
and everything which is indented by two blanks
is now a direct child of services
and services needs
at least one child element
possibly multiple children.
Now what are the children of services though?
That will be your containers.
And since our application here
has three containers,
we will have three child elements here below services.
Now you can choose names
of your choice to label these containers
to give these containers a name.
And I will name one container backend,
one container frontend,
and maybe first one container mongodb.
Now these names are up to you.
You can use any names you want here.
They should all be on the same level though.
All indented by two blanks,
since they all are equal children to services.
With that we're defining
that our application, our project
will use three containers.
Now of course that's just the start.
Now we can define a configuration
for every container
and you might already be guessing it.
We do that by indenting again.
So now I indent here below mongodb
to set up the options
that belong to the mongodb container.
And we'll do something similar
for backend and for frontend
we'll indent by two more blanks here.
So four blanks in total,
and then that's the configuration
for mongodb, backend and so on.
So that's what we'll continue with
because now we can dive into the configurations
for the individual containers.