Compose's project .env file supplies interpolation values. To give one of those values to a container, reference it in the service configuration.

For example, .env contains the proxy endpoint:

HTTP_PROXY=http://203.0.113.10:8080

The service uses it for both HTTP and HTTPS destination requests:

services:
  app:
    image: your-image
    environment:
      HTTP_PROXY: "${HTTP_PROXY}"
      HTTPS_PROXY: "${HTTP_PROXY}"

Replace the documentation address and image; select a compatible HTTP endpoint from your service or the HTTP proxy list. An ordinary HTTP proxy can carry HTTPS through CONNECT if it supports the requested tunnel.

An explicit env_file entry is another way to pass a chosen file's variables to a service. The project interpolation file does not act as an implicit container env_file.

Checking what reached the application

docker compose config shows the resolved service configuration. docker compose config --environment instead shows the values used for interpolation.

Compare the service environment with the application process. An existing container does not receive new values when you edit .env; apply the change through the intended Compose lifecycle, allowing for service interruption.

If the variable is absent, fix the service configuration. If it is present but requests remain direct, check the HTTP client's proxy support. Environment injection supplies configuration; the application must consume it.

Artiglyn mynjee