Overview
Important
Docker's documentation refers to and describes Compose V2 functionality.
Effective July 2023, Compose V1 stopped receiving updates and is no longer in new Docker Desktop releases. Compose V2 has replaced it and is now integrated into all current Docker Desktop versions. For more information, see Migrate to Compose V2.
Use environment variables to pass configuration information to containers at runtime.
Environment variables are key-value pairs that contain data that can be used by processes running inside a Docker container. They are often used to configure application settings and other parameters that may vary between different environments, such as development, testing, and production.
Tip
Before using environment variables, read through all of the information first to get a full picture of environment variables in Docker Compose.
This section covers:
- The various ways you can set environment variables with Compose.
- How environment variable precedence works.
- The correct syntax for an environment file.
- Changing pre-defined environment variables.
- Some best practices.