docs/compose/reference/envvars.md

5.2 KiB

description keywords title
Compose CLI environment variables fig, composition, compose, docker, orchestration, cli, reference Compose CLI environment variables

In this section you can find the list of pre-defined environment variables you can use to configure the Docker Compose command-line behavior.
See also Declare default environment variables in file to check how to declare default environment variables in an environment file named .env placed in the project directory.

COMPOSE_PROJECT_NAME

Sets the project name. This value is prepended along with the service name to the container's name on startup.

For example, if your project name is myapp and it includes two services db and web, then Compose starts containers named myapp-db-1 and myapp-web-1 respectively.

  • Defaults to: the basename of the project directory.

See also the command-line options overview and using -p to specify a project name.

COMPOSE_FILE

Specifies the path to a Compose file. Specifying multiple Compose files is supported.

  • Default behavior: If not provided, Compose looks for a file named compose.yaml or docker-compose.yaml in the current directory and, if not found, then Compose searches each parent directory recursively until a file by that name is found.

  • Default separator: When specifying multiple Compose files, the path separators are, by default, on:

    • Mac and Linux: : (colon),
    • Windows: ; (semicolon).

The path separator can also be customized using COMPOSE_PATH_SEPARATOR.
Example: COMPOSE_FILE=docker-compose.yml:docker-compose.prod.yml.
See also the command-line options overview and using -f to specify name and path of one or more Compose files.

COMPOSE_PROFILES

Specifies one or more profiles to be enabled on compose up execution. Services with matching profiles are started as well as any services for which no profile has been defined.

For example, calling docker compose upwith COMPOSE_PROFILES=frontend selects services with the frontend profile as well as any services without a profile specified.

  • Default separator: specify a list of profiles using a comma as separator.
    Example: COMPOSE_PROFILES=frontend,debug
    This example would enable all services matching both the frontend and debug profiles and services without a profile.

See also Using profiles with Compose and the --profile command-line option.

DOCKER_HOST

Sets the URL of the Docker daemon.

  • Defaults to: unix:///var/run/docker.sock(same as with the Docker client).

DOCKER_TLS_VERIFY

See DOCKER_TLS_VERIFY on the Use the Docker command line{:target="blank" rel="noopener" class=""} page.

DOCKER_CERT_PATH

Configures the path to the ca.pem, cert.pem, and key.pem files used for TLS verification.

  • Defaults to: ~/.docker.

See, DOCKER_CERT_PATH on the Use the Docker command line{:target="blank" rel="noopener" class=""} page.

COMPOSE_CONVERT_WINDOWS_PATHS

When enabled, Compose performs path conversion from Windows-style to Unix-style in volume definitions.

  • Supported values:
    • true or 1, to enable,
    • false or 0, to disable.
  • Defaults to: 0.

COMPOSE_PATH_SEPARATOR

Specifies a different path separator for items listed in COMPOSE_FILE.

  • Defaults to:
    • On Mac and Linux to :,
    • On Windows to;.

COMPOSE_IGNORE_ORPHANS

When enabled, Compose doesn't try to detect orphaned containers for the project.

  • Supported values:
    • true or 1, to enable,
    • false or 0, to disable.
  • Defaults to: 0.

Deprecated in Compose v2

Important

The environment variables listed below are deprecated in v2.

COMPOSE_API_VERSION

Deprecated in v2.
By default the API version is negotiated with the server. Use DOCKER_API_VERSION.
See DOCKER_API_VERSION on the Use the Docker command line{:target="blank" rel="noopener" class=""} page.

COMPOSE_HTTP_TIMEOUT

Deprecated in v2.

COMPOSE_TLS_VERSION

Deprecated in v2.

COMPOSE_FORCE_WINDOWS_HOST

Deprecated in v2.

COMPOSE_PARALLEL_LIMIT

Deprecated in v2.

COMPOSE_INTERACTIVE_NO_CLI

Deprecated in v2.
As v2 now uses the vendored code of Docker CLI{:target="blank" rel="noopener" class=""}.

COMPOSE_DOCKER_CLI_BUILDx

Deprecated in v2.
Use DOCKER_BUILDKIT to select between BuildKit and the classic builder. If DOCKER_BUILDKIT=0 then docker build uses the classic builder to build images.