We looked at Docker Compose in chapter 7, and you gained a good understanding of how to use YAML to describe a multi-container application and manage it with the Compose command line. Since then we’ve enhanced our Docker applications to get them ready for production with health checks and monitoring. Now it’s time to return to Compose, because we don’t need all those production features in every environment. Portability is one of Docker’s major benefits. When you package your application to run in containers, it works the same way wherever you deploy it, and that’s important because it eliminates drift between environments.
Drift is what always happens when manual processes are used to deploy software. Some updates get missed or some new dependencies are forgotten, so the production environment is different from the user test environment, which is different again from the system test environment. When deployments fail, it’s often because of drift, and it takes a huge amount of time and effort to track down the missing pieces and put them right. Moving to Docker fixes that problem because every application is already packaged with its dependencies, but you still need the flexibility to support different behavior for different environments. Docker Compose provides that with the more advanced features we’ll cover in this chapter.