concept override file in category docker

appears as: override files, The override files, override file, The override file, n override file, An override file, override files
Learn Docker in a Month of Lunches

This is an excerpt from Manning's book Learn Docker in a Month of Lunches.

10.2 Using Docker Compose override files

Teams hit the problem of trying to run different app configurations with Docker Compose and often end up with many Compose files--one for each environment. That works, but it’s not maintainable, because those Compose files are often 90% duplicated content, which means they’ll get out of sync and you’re back to a drift situation. Override files are a much neater approach. Docker Compose lets you merge multiple files together, with properties from later files overriding those from earlier in the merge.

Figure 10.4 Removing duplication with override files that add environment-specific settings

This approach is maintainable. If you need to make a change that applies to all environments--like changing an image tag to use the latest version--you do that once in the core file, and it filters through to every environment. If you just need to change one environment, you only change that single file. The override files you have for each environment also serve as clear documentation of the differences between environments.

# this would work if we'd used the default docker-compose.yml file:
 docker-compose down
 
 # this would work if we'd used override files without a project name:
 docker-compose -f ./numbers/docker-compose.yml -f ./numbers/docker-compose-test.yml down
 
 # but we specified a project name, so we need to include that too:
 docker-compose -f ./numbers/docker-compose.yml -f ./numbers/docker-compose-test.yml -p numbers-test down