Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables not being set by `docker-compose run -e VAR=VALUE` #6889

abl opened this issue Sep 8, 2019 · 2 comments


Copy link

commented Sep 8, 2019

Description of the issue

Using docker-compose I'm unable to get environment variables to be set at runtime. This is applying both to docker-compose up and docker-compose run with -e overrides. docker run works as expected.

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.0j  20 Nov 2018

Output of docker version

 Version:           18.09.6
 API version:       1.39
 Go version:        go1.11
 Git commit:        8cdf373
 Built:             Thu Aug 15 06:47:17 2019
 OS/Arch:           linux/amd64
 Experimental:      false

  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.11
  Git commit:       62fd7b0
  Built:            Thu Aug 15 06:45:45 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

    container_name: letsencrypt-dns
      LEXICON_LINODE4_TTL: '300'
      LEXICON_PROVIDER: linode4
      LEXICON_SLEEP_TIME: '1200'
    image: adferrand/letsencrypt-dns:latest
      driver: json-file
        max-size: 10m
    - /volume1/docker/letsencrypt-dns:/etc/letsencrypt:rw
    - /var/run/docker.sock:/var/run/docker.sock:rw
version: '3.0'

Steps to reproduce the issue

  1. docker-compose run --rm -e LETSENCRYPT_STAGING=true letsencrypt-dns env | grep LETSENCRYPT_STAGING
  2. docker run --rm -e LETSENCRYPT_STAGING=true adferrand/letsencrypt-dns env | grep LETSENCRYPT_STAGING
  3. Attempt to run the above docker-compose.yml and note that all environment variables are as their defaults in the Dockerfile.

Observed result

  3. Various failures in the logs as all environment variables are set to their defaults.

Expected result

  3. Success.

Stacktrace / full error message


Additional information

Synology DSM 6.2.2-24922 Update 2 (synology_apollolake_918+); docker-compose installed via curl.


This comment has been minimized.

Copy link

commented Sep 8, 2019

I'm having the same issue here, except it is complaining with the following:

ERROR: Invalid interpolation format for "environment" option in service "back-end": ENVIRONMENT Variable

I'm using a ".env" file in my project.
It is complaining about the first environment line, "VAR1: ${ENV_VAR1}", in my compose formatted as the following:

    VAR1: ${ENV_VAR1}
    VAR2: ${ENV_VAR2}
    VAR3: ${ENV_VAR3}

When I escaped the $ on each environment declaration, "VAR1: $${ENV_VAR1}", it ran the compose, but the environment variables were undefined, as expected. Did something happen to the interpreter for the Docker Compose YAML?

P.S. I did have 1 line with a $ in the ".env", but it was something that I was not using, so I deleted the line outright, but I am still receiving this error.


This comment has been minimized.

Copy link

commented Sep 9, 2019

Also of note - none of the variables in the environment section are set during run or up.

This YAML worked before so I assumed it was an issue in the Dockerfile but I can’t explain why docker run has different behavior.

No errors are surfaced by docker or docker-compose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.