allow user variables to be set from environment
User-specific configuration data such as passwords are better passed via the environment, as explained by the third principle of 12-factor apps:
- https://12factor.net/config
This avoids the issues with checking passwords or other user data into git (either deliberately or accidentally). It also ensures that each piece of configuration has a single source of truth, with matching values everywhere it is used, e.g. that the same value for MAUTIC_DB_PASSWORD is passed to both the mautic and mysql services.
These variables can either be exported in the environment invoking docker-compose:
- https://docs.docker.com/compose/environment-variables/
or by placing them in an .env file:
- https://docs.docker.com/compose/env-file/
Another example is COMPOSE_PROJECT_NAME, which is worth setting in order to avoid ambiguity if there are other containers named mysql or nginx on the same system.