Image

Centralize Docker Configuration with an Environment File

One of the problems with Dockerizing an existing project is that configuration information tends to proliferate everywhere. Not only do we have settings in docker-compose.yml, but also in our Docker-specific settings file settings.docker.php. If we change a setting in one place we need to copy and paste it everywhere else. This can make things difficult if we suddenly have the need to change a setting.

Fortunately, there's a way to centralize Docker configuration for our project by using an environment file.

In this tutorial, we'll:

  • Review what an environment file is and its format.
  • List the advantages of moving Docker configuration to an environment file.
  • Describe the .env file, and how it provides us further advantages.