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 create docker registry mirror
  • Redis as session storage for WordPress in docker
  • Restart ghost blog running inside Docker
  • docker-machine amazon-ec2 fail during init
  • Why the docker keeps both image and image container on VM?
  • docker-machine ls shows state timeout
  • What then, should I change in my syntax?

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

  • Weblogic + Docker + Vagrant = Connection Issue
  • Access a docker containers own localhost inside that container — php apache
  • How To Run Docker Commands Asynchronously?
  • How can I update DOCKER_OPTS in docker-machine permanently
  • Can Docker 1.12 in “swarm mode” provide “a single, virtual Docker host”?
  • Asp.NET on Linux using Mono
  • 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.

    https://docs.docker.com/reference/builder/#onbuild

    else

    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.