Skip to content

docker-compose environment variables not respected #298

@CarlHostetter-NASA

Description

@CarlHostetter-NASA

It appears that the docker-gen container does not "see" or respect environment variables set by docker-compose. Here is my docker-gen service:

docker-gen:
    image: jwilder/docker-gen
    container_name: docker-gen
    command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    depends_on:
        - nginx-proxy
    volumes:
        - ../certs:/etc/nginx/certs:ro
        - ./docker-gen/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl
        - /var/run/docker.sock:/tmp/docker.sock
        - nginx-proxy-conf:/etc/nginx/conf.d
        - nginx-proxy-vhosts:/etc/nginx/vhost.d
    environment:
        - DEFAULT_HOST=foo.bar
        - FOO=bar

However, neither FOO nor (more importantly) DEFAULT_HOST are respected as environment variables within the docker-gen container.

This in turn causes the default_server option not to be set when generating default.conf from the nginx.tmpl of nginx-proxy:

{ $default_host := or ($.Env.DEFAULT_HOST) "" }}
{{ $default_server := index (dict $host "" $default_host "default_server") $host }}

...

server {
server_name {{ $host }};
listen 443 ssl http2 {{ $default_server }};

and I need that to be set for proper security.

Please help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions