A Docker Compose Override File Can Help Avoid Compose File Duplication
An override file lets you use the same Docker Compose file in development and production while being able to run different services.
I Moved to Using Docker Compose Profiles
In September 2022 I switched away from an override file to using profiles.
Read Why I SwitchedOne of my favorite features of Docker Compose is the override file. It lets
you reuse a single docker-compose.yml
file across development and production
even if you happen to run different services in both environments.
In this video we’ll go over 2 real world use cases, such as running a Webpack watcher container in development but not in production and also see how you can use the same pattern to run a database in development while using a managed database service in production.
The best part about it is, we’ll get to use the same main Docker Compose file and situationally load these other services in development by using an override file.
# Applying the Docker Compose Override File Pattern
Timestamped Table of Contents
- 0:41 – Comparing a regular Docker Compose YAML file to an override file
- 2:10 – Seeing how the Docker Compose override file works in practice
- 3:48 – The example file lets you ignore the real override file from version control
- 5:58 – The override file works great for Webpack and managed databases
- 7:18 – This pattern lets you re-use a single Compose file in dev and production
Reference Links
- Build a SAAS App with Flask course
- https://github.com/nickjj/build-a-saas-app-with-flask
- Dive into Docker playlist on YouTube
- Dive into Docker course
- https://nickjanetakis.com/blog/a-few-advantages-of-using-webpack-in-your-next-project
Are you using the Docker Compose override file pattern? Let me know below.