Using env vars in a docker cmd?

I have this line in my Dockerfile:

CMD [“rqworker”, “–host=$REDIS_MASTER_SERVICE_HOST”]

  • how to protect a django web app deployed in elastic beanstalk docker nginx using password
  • Reusing docker environment variables in CLI
  • Ignore directories with .dockerignore or volume?
  • Docker: trouble connecting to mysql, network issue?
  • Jenkins and SonarQube in same dockerfile
  • Mount Docker volume on host but make files “immutable”?
  • 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?

  • Unable to access web app from outside docker container
  • Static webpage on Nginx Docker Container Missing CSS
  • Small change in large file in Docker container produces huge layer
  • Access Docker Container App from phone on local network
  • Accessing rabbitmq running on local machine from docker container
  • Docker container: Huge size for Node.js-based microservice
  • One Solution collect form web for “Using env vars in a docker cmd?”

    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

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.