Using env vars in a docker cmd?

4/11/2015

I have this line in my Dockerfile:

CMD ["rqworker", "--host=$REDIS_MASTER_SERVICE_HOST"]

REDIS_MASTER_SERVICE_HOST is set by Kubernetes, and works fine when accessed within my python app. I need to point rqworker to it, but it doesn't seem to be expanded:

redis.exceptions.ConnectionError: Error -2 connecting to $REDIS_MASTER_SERVICE_HOST:6379. Name or service not known.

How can I get docker to expand it into the actual value?

-- user964375
docker
kubernetes

1 Answer

9/18/2015

Variable expansion is supported in kubernetes with the $(VAR) syntax. Please see this doc:

http://docs.k8s.io/v1.0/user-guide/configuring-containers.html#environment-variables-and-variable-expansion

-- Tim Hockin
Source: StackOverflow