Managing multiple environments with Docker Compose
In this section, we will learn how to prepare our Compose YAML files as templates for running our applications in different environments and under different circumstances, such as developing or debugging.
If you are familiar with the use of environment variables in different operating systems, this section will seem pretty easy. We already learned how to use variables to modify the default behavior of Dockerfiles (Chapter 2, Building Docker Images) and containers at runtime (Chapter 4, Running Docker Containers). We used variables to overwrite the default values defined and modify the build
process or the execution of container image processes. We will use the same approach with Compose YAML files. We will now review some of the different options we have to use variables with the docker-compose
command line.
We can define a .env
file with all the variables we are going to use in a Compose YAML file defined as a template. Docker...