Docker Community Forums

Share and learn in the Docker community.

Environment set in docker-compose

docker

(Bill Wang) #1

I can’t run docker-compose.yml with environment variables.

This works with proxy setting.

$ cat docker-compose.yml

bamboo-server:
    image: matisq/bamboo-server
    ports:
        - 8085:8085
        - 54663:54663
    links:
        - postgres
    environment:
        BAMBOO_VERSION: ${BAMBOO_VERSION}
        BAMBOO_HOME: /home/bamboo
        BAMBOO_BAMBOO_SERVER_ID: bamboo-server
        http_proxy: http://192.168.65.1:3128
        https_proxy: http://192.168.65.1:3128

But why this doesn’t:

$ cat .env
BAMBOO_VERSION=6.3.2
http_proxy=http://192.168.65.1:3128
https_proxy=http://192.168.65.1:3128

$ cat docker-compose.yml
bamboo-server:
    image: matisq/bamboo-server
    ports:
        - 8085:8085
        - 54663:54663
    links:
        - postgres
    environment:
        BAMBOO_VERSION: ${BAMBOO_VERSION}
        BAMBOO_HOME: /home/bamboo
        BAMBOO_BAMBOO_SERVER_ID: bamboo-server
        http_proxy: ${http_proxy}
        https_proxy: ${https_proxy}

Error messages:

bamboo-server_1  | Connecting to localhost (localhost)|127.0.0.1|:3128... failed: Connection refused.
bamboo-server_1  | Connecting to localhost (localhost)|::1|:3128... failed: Cannot assign requested address.
bamboo-server_1  | Retrying.

(Bill Wang) #2

Answer my own question, seems the environment variables have been defined as uppercase letter

    http_proxy: ${HTTP_PROXY}
    https_proxy: ${HTTPS_PROXY}