Skip to content
masterclass Buddy

Docker · Option

environment

Set variables in Compose with environment, or load them from files with env_file. Use docker compose run -e for a temporary value on one command.

Last updated

Syntax

services:
  <service>:
    environment:
      NAME: value
    env_file: path/to/file.env

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • environment
  • env_file
  • docker compose run --env
  • docker run --env-file
  • secrets

Source: Set environment variables within your container's environment. Checked 2026-11-03.