Using Docker Compose overrides
Sometimes, we want to run our applications in different environments that need specific configuration settings. Docker Compose provides a handy capability to address exactly this issue.
Let’s illustrate the with a specific sample:
- Open a new browser window and navigate to the chapter’s folder (
ch11
):$ cd ~/The-Ultimate-Docker-Container-Book/ch11
- Create a subfolder called
step4
and navigate to it:$ mkdir step4 && cd step4
- Copy the
web
anddb
folder and their contents from thestep2
folder into thestep4
folder:$ cp -r ../step2/web .$ cp -r ../step2/db .
- We can define a base Docker Compose file and then define environment-specific overrides. Let’s assume we have a file called
dockercompose.base.yml
with the following content:
Figure 11.23 – Docker Compose file used as a base
This only defines the part that should be the same in all environments. All specific settings...