ENV

ENV is a Dockerfile instruction that sets the environment variable <key> to the value <value>. You have two options for using ENV:

  • The first one, ENV <key> <value>, will set a single variable to a value. The entire string after the first space will be treated as the <value>. This will include any character, and also spaces and quotes. For example:
ENV JAVA_HOME /var/lib/java8
  • The second one, with an equal sign, is ENV <key>=<value>. This form allows setting multiple environment variables at once. If you need to provide spaces in the values, you will need to use quotes. If you need quotes in the values, use backslashes:
ENV CONFIG_TYPE=file CONFIG_LOCATION="home/Jarek/my \app/config.json"

Note that you can use ENV to update the PATH ...

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.