18 Application configuration management in containers
Applications need to load their configuration from the environment they’re running in, which is usually a combination of environment variables and files read from disk. Docker creates that environment for apps running in containers, and it can set environment variables and construct a filesystem from many different sources. The pieces are all there to help you build a flexible configuration approach for your apps, so when you deploy to production, you’re using the same image that passed all the test phases but you inject the settings you need for the live environment. You just need to do some work to bring the pieces together, setting up your app to merge configuration values from multiple places.
This chapter will take you through the recommended approach (and some alternatives) using examples in .NET, Java, Go, and Node.js. Some of the work here lives in the developer space, bringing in libraries to provide config management, and the rest lives in that gray area between dev and ops that relies on communication so that both sides know how the configuration model works.
18.1 A multi-tiered approach to app configuration
Your configuration model should reflect the structure of the data you’re storing, which is typically one of three types: