title: Docker variable expansion
body: <p>Is there a way to do variable expansion within the ENV section of a dockerfile? In the example below I would like javaMemoryLimit to be expanded within JAVA_OPTS but I find when I run the image the java process exists as instead of having <strong>-Xmx1024M</strong> we are left with <strong>-Xmx</strong></p>
  
  <pre><code>FROM azul/zulu-openjdk-centos:latest
  VOLUME /tmp
  ADD myspecificcode.jar app.jar
  RUN bash -c 'touch /app.jar'
  ENV javaMemoryLimit="1024M"\
      JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Dsun.rmi.dgc.client.gcInterval=3600000 -XX:+MaxFDLimit -XX:+ExplicitGCInvokesConcurrent -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -Xmx$javaMemoryLimit"
  ENTRYPOINT java $JAVA_OPTS -jar /app.jar
  </code></pre>
  
  <p>I've got the following working but would rather it was all done via modifying the JAVA_OPTS variable rather than adding additional switches to the java command:</p>
  
  <pre><code>FROM azul/zulu-openjdk-centos:latest
  VOLUME /tmp
  ADD myspecificcode.jar app.jar
  RUN bash -c 'touch /app.jar'
  ENV javaMemoryLimit="1024M"\
      JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Dsun.rmi.dgc.client.gcInterval=3600000 -XX:+MaxFDLimit -XX:+ExplicitGCInvokesConcurrent -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC"
  ENTRYPOINT java $JAVA_OPTS  -Xmx$javaMemoryLimit -jar /app.jar
  </code></pre>