Docker use variables in conf file? Docker use variables in conf file? docker docker

Docker use variables in conf file?


You can use environment variables is your compose file. According to official docs

Your configuration options can contain environment variables. Compose uses the variable values from the shell environment in which docker-compose is run. For example, suppose the shell contains POSTGRES_VERSION=9.3 and you supply this configuration:

db: image: "postgres:${POSTGRES_VERSION}"

When you run docker-compose up with this configuration, Compose looks for the POSTGRES_VERSION environment variable in the shell and substitutes its value in.

See the docs for more information. You will find various other approaches to supply environment variables in the link like passing them through env_file etc.