Skip to content

docker-compose does not set environment variables #7423

@Kytech

Description

@Kytech

Description of the issue

When using docker-compose up or docker-compose run -e ENVIRONMENT_VAR=value, environment variables are not being applied either through the -e command line parameters or from the docker-compose.yml file.

The docker-compose.yml file I am using is as follows:

version: '3'
services:
    nginx-reverse-proxy:
        image: nginx
        volumes:
         - C:/Users/<Username>/nginx-reverse-proxy/configdir:/etc/nginx/conf.d/
        ports:
         - "80:80"
        environment:
            NGINX_SERVER_NAME: "test.mysite.org"
            NGINX_REMOTE_URL: "http://remote.mysiteengine.somehost.com:13345"

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.25.5, build 8a1c60f6

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker-compose config

WARNING: The NGINX_SERVER_NAME variable is not set. Defaulting to a blank string.
WARNING: The NGINX_REMOTE_URL variable is not set. Defaulting to a blank string.
services:
  nginx-reverse-proxy:
    environment:
      NGINX_SERVER_NAME: "test.mysite.org"
      NGINX_REMOTE_URL: "http://remote.mysiteengine.somehost.com:13345"
    image: nginx
    ports:
    - 80:80/tcp
    volumes:
    - C:\Users\<Username>\nginx-reverse-proxy\configdir:/etc/nginx/conf.d/:rw
version: '3.0'

Steps to reproduce the issue

  1. Create a docker-compose.yml file that sets environment variables
  2. Run docker-compose up

Observed result

Environment Variables are not applied

Expected result

Environment variables should be applied to containers started by docker-compose

Stacktrace / full error message

WARNING: The NGINX_SERVER_NAME variable is not set. Defaulting to a blank string.
WARNING: The NGINX_REMOTE_URL variable is not set. Defaulting to a blank string.
Creating network "nginx-reverse-proxy_default" with the default driver

Additional information

OS Version: Windows 10 Pro v1909,
docker-compose install method: Docker Desktop for Windows Installer, followed by manual upgrade of docker-compose (Issue occurred on docker-compose version 1.25.4 which was included with Docker Desktop and with manual upgrade to 1.25.5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions