So what is Docker Compose?
It's really easy to understand in the end.
Docker Compose is a tool that allows you to replace
Docker build and Docker run commands
and they're not just one Docker build
and one Docker run command,
but potentially multiple Docker build
and Docker run commands with just one configuration file
and then a set of orchestration commands
to start all those services, all these containers at once
and build all necessary images, if it should be required
and you then also can use one command to stop everything
and bring everything down and that will be great
because whilst you can, of course already
store Docker commands in any text file of your choice,
and then just copy and paste them into your terminal,
whilst you can already do that of course,
this is not super convenient.
And with Docker Compose, that will be much more convenient
because with Docker Compose, you will have
one configuration file using a clearly defined language
which you can share with anyone
and then it's just one command, no command copy and pasting
just one command which will leverage this configuration file
and which will then bring up or bring down
your entire multicontainer application.
Of course, just as a side note,
you can also use Docker Compose
in a single container application,
it just shines the most if you have multiple containers
because there, you can simply save a lot of extra commands
and therefore time.
I also briefly wanna highlight what Docker Compose
is not though just to make this also clear.
Docker Compose will not replace Docker files
for custom images.
You will see this in this module,
Docker Compose works together with Docker files.
It does not replace them.
Docker Compose also does not replace images or containers.
It just makes working with them easier,
it makes launching containers ways easier
and also important, Docker Compose is not suited
for managing multiple containers on different hosts.
At least that's not its primary strength.
Docker Compose is really great for managing
multiple containers on one and the same host
and we'll talk about deploying containers to single
and multiple hosts in the deployment section.
For the moment we're running everything on
our hosting machine, which is just one machine
and therefore one host and therefore at the moment,
Docker Compose is perfect and in general,
it's a super powerful Docker tool, which you will use a lot
in reality for development, but also for things
beyond development, as you will learn
throughout this course.
Okay, so Docker Compose sounds quite interesting,
how do we get with it?
You always start by writing a Docker Compose file.
Unlike Docker without compose,
it's not primarily about executing commands in the terminal.
Instead the idea is that you can save time there
and therefore you put a lot of configuration
into this Docker Compose file.
And in this file,
you need just define a couple of core things,
a couple of core components that make up
your multicontainer application.
The heart and most important element
or thing you can define in a compose file
and you must define in a compose file
are the so-called services which in the end
can be translated with containers
that make up your multicontainer application.
But then below every service you can configure that service.
And when I say service here, I really just mean container.
You can define which port should be published,
which environment variables this container might need.
You can define volumes that should be assigned
to this container.
You can assign networks
and you can do basically everything you can do with
Docker command in the terminal otherwise,
because the idea really is
that we replace running these Docker commands
in the terminal, that is the idea of compose.
And therefore I'd say enough of the theory,
let's get started and let's simply work on that project
we built in the last module and let's use compose
instead of running all these individual commands.