Configuration options in Docker Compose allow for customization of the application model and include using environment variables and command-line arguments.
Environment variables in Docker Compose can be set in various ways, including using the COMPOSE_PROFILES
environment variable to specify one or more profiles to be enabled on compose up
execution. The Compose file version 2.x added the priority
key to service network mappings, allowing the user to define in which order the specified service will connect to each network.
Compose files can be merged using the -f
option, which allows for the use of multiple Compose files and override files. When using multiple Compose files, all paths in the files must be relative to the base Compose file.
Command-line arguments in Docker Compose include the -p
flag to specify a project name, which can be set in different ways including through the COMPOSE_PROJECT_NAME
environment variable or the top level name:
variable in the config file.
The docker stack deploy
command allows for the deployment of a Docker application on a swarm by using a Compose file. The docker compose config
command renders the actual data model to be applied on the Docker engine, merging the Compose files set by -f
flags, resolving variables in the Compose file, and expanding short-notation into the canonical format.
Docker Compose also supports the use of profiles, which help adjust the Compose application model for various uses and environments by selectively starting services. Services can be assigned to zero or more profiles, and if assigned, they are only started if the profile is activated.
For more information, please refer to the following resources:
- Migrate to Compose V2: https://docs.docker.com/compose/migrate
- Set or change pre-defined environment variables in Docker Compose: https://docs.docker.com/compose/environment-variables/envvars
- Docker Compose release notes: https://docs.docker.com/compose/release-notes
- Merge Compose files: https://docs.docker.com/compose/multiple-compose-files/merge
- docker stack deploy: https://docs.docker.com/engine/reference/commandline/stack_deploy
- Overview of docker compose CLI: https://docs.docker.com/compose/reference
- docker compose config: https://docs.docker.com/engine/reference/commandline/compose_config
- Reference for Visual Studio Code Docker extension properties and tasks: https://code.visualstudio.com/docs/containers/reference
- Using profiles with Compose: https://docs.docker.com/compose/profiles
- Overview: https://docs.docker.com/compose/environment-variables
- The Compose file: https://docs.docker.com/compose/compose-file