Setting Dynamic Env variable in Docker

I am trying to set dynamic env variable in Docker but somehow it resets.
I want to set an ENV variable which has value :

export EC2_Region=$(curl -s 

so i cant just use ENV in Dockerfile since its not static.

  • Jackrabbit with PostgreSQL backend leaves repository in inconsistent state
  • Transparent proxy tunneling individually for each Docker container
  • Ansible error due to GMP package version on Centos6
  • Docker - Cannot remove dead container
  • How to get Docker work properly from within the msys2 bash?
  • Deploying scala app as a docker container
  • I tried making an and used CMD[""] in Dockerfile but when i attach to the docker process, the env variable is empty.

    I am fairy new to docker and still exploring options.

    Thanks in advance !

  • Make Docker4Mac and vagrant see each others network
  • Use environment vars of container in command key of docker-compose
  • Stop a Nginx Docker container
  • understanding docker volume : can i create a volume and assign it to the specific container /service?
  • Wifi connection dropped after docker start
  • How to use ipaddreses instead of container names in docker compse networking
  • One Solution collect form web for “Setting Dynamic Env variable in Docker”

    You can use ENTRYPOINT instead of CMD.

    Example Dockerfile:

    FROM ubuntu:14.04
    COPY /
    RUN chmod +x /
    ENTRYPOINT ["/"]

    export EC2_Region=$(curl -s
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.