Using env vars in a docker cmd?

I have this line in my Dockerfile:

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

  • Run Python script in one docker-compose container in another
  • gcloud docker not working on Compute Engine VM
  • Default Docker entrypoint
  • Force Docker to cache directory
  • Docker container vs Java Virtual Machine
  • Error creating Docker container in Bluemix
  • 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?

  • Clean Docker /var/lib/docker/devicemapper
  • Run DDL-script generated by Entity Framework does not create tables in Docker container
  • Dockerfile drupal console access denied mkdir
  • Docker: listen for .sql changes and re-provision database
  • AWS Beanstalk docker image automatic update doesn't work
  • Docker push re-sends layers to private repository
  • 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:

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