docker-archive / dockercloud-haproxy

HAproxy image that autoreconfigures itself when used in Docker Cloud
https://cloud.docker.com/
651 stars 187 forks source link

Swarm: Specifying config environment variables in Dockerfile #186

Closed devcoder18 closed 7 years ago

devcoder18 commented 7 years ago

I am specifying the environment variables for my swarm service in the Dockerfile used to build the original image. I do docker service create without -e command-line arguments (because they are already specified for the container when it's image was built). I checked the haproxy container logs but it is not picking up configurations for SERVICE_PORTS, VIRTUAL_HOST or EXTRA_SETTINGS and requests are not proxied.

tifayuki commented 7 years ago

@devcoder18

dockercloud/haproxy reads the environment variable from the "inspect" of the application services/containers. If you set it in them in Dockerfile, they cannot be read by dockercloud/haproxy. This explains why it doesn't work.

You have to set the environment variable in the runtime.