Creating Dockerfile with Environmental Variables

I’m trying to create a docker image that will run a command for the users. The command will need a number of variable entries, specific for the person running it. I tried simply creating it with the variables and, because the command couldn’t be run upon build, the process wouldn’t complete. I then tried using the ‘${varname:-possible value}, and I got a little further.

I’m guessing part of the problem may be that some of the variables are URLs, since the folder name, also a variable, is being accepted. I did try adding escape characters (‘\’) to all the special characters in the URL and all that did was get me a ‘bad substitution’ error instead.

  • How to update docker stack without restarting all services
  • How to collect docker logs to a particular docker container in compose?
  • bluemix “docker images” results in “json: cannot unmarshal string into Go value of type int”
  • Is there any way to get a snapshot of docker stats?
  • Proxying http requests to another docker container
  • How to convert docker-compose setup to docker image?
  • What then, should I change in my syntax?

    RUN /usr/bin/java -jar export.jar calendar \
        --output /var/www \
        --format public \
        --restUri ${one_uri:-} \
        --daysForward ${days_forward:-30}

  • Installing packages for Rstudio Docker
  • Install Oracle on docker centos container: Insufficient disk space
  • Debug Nodejs inside Docker container
  • kafka-node LeaderNotAvailable errors on send
  • How to run ansible script inside a docker container
  • Running a Docker container with the -p or -P flag causes it to fail
  • One Solution collect form web for “Creating Dockerfile with Environmental Variables”

    I don’t exactly get if your users is building their own Dockerfile or they are using your docker image directly, but if they create their own, then you can use ONBUILD to run a command that will when the user docker build their container.


    you can just specify your own defaults like this

    ENV days_forward "30"

    and then they can easily overwrite that environment variable when they run your container.

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