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. 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 Core, 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 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:

  • Release-level settings, which are the same for every environment for a given release
  • Environment-level settings, which are different for every environment
  • Feature-level settings, which can be used to change behavior between releases

18.2 Packaging config for every environment

18.3 Loading configuration from the runtime

18.4 Configuring legacy apps in the same way as new apps

18.5 Understanding why a flexible configuration model pays off

18.6 Lab