Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

A Docker Compose Override File Can Help Avoid Compose File Duplication

blog/cards/a-docker-compose-override-file-can-help-avoid-compose-file-duplication.jpg

An override file lets you use the same Docker Compose file in development and production while being able to run different services.

Quick Jump: Applying the Docker Compose Override File Pattern

I moved to using Docker Compose profiles

In September 2022 I switched away from an override file to using profiles.

Read why I switiched

One 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

Are you using the Docker Compose override file pattern? Let me know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per month (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments