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.

  • Docker not running on OS/X
  • exposing container ports for django application
  • “bash: fork: retry: No child processes ” when running docker quick start terminal or in /git bash shell
  • How do you setup an AWS Elastic Beanstalk Docker Platform running Django?
  • cannot access Docker remote registry
  • Why does the thrift docker image need go
  • 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}

  • Can't add a user with a high UID in docker Alpine
  • docker : can't mount some directory from host
  • tf-random won't install in Docker container
  • Linking Containers / Building Images In Docker
  • Open port between docker containers
  • Kubernetes cluster nodes become unresponsive
  • 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.