O'Reilly logo

Docker and Kubernetes for Java Developers by Jaroslaw Krochmalski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required