https://codereviewvideos.com/course/docker-tutorial-for-beginners/video/docker-compose-multiple-environments

docker-tutorial.jpg

At this stage we have all the knowledge required to quickly get up and running with Docker.

There are always more things to learn about Docker, both broad strokes and deep dives. But my personal approach is to get enough knowledge to start confidently playing with a technology, and let the real world dictate what I need to learn next.

A big part of using Docker in the real world - in my personal experience - is in using Docker in different environments.

I always have my Dockerised development environment.

To begin with, all of this config lives inside docker-compose.yml.

But once I get serious about a project, I often need at least two, but usually several different configurations. It depends on the environment and project requirements.

Often the ports I use in development won't be those I use in staging, or production.

Likewise, volumes may have different paths on underlying disk, or using images with differing tags, and so on.

Fortunately Docker Composer caters to this need.

As a heads up, what we will end up with is something like:

And so on.

I typically don't have a configuration for production. This is because my production configurations live elsewhere, and will be covered in a different tutorial. I use Rancher in production, which is currently undergoing a dramatic change between 1.0 and 2.0 releases, so as of the time of recording, I have had to hold back on releasing that course.

What Lives In Each Environment?