What is the best way to set environment variables permanently?

On docker build file, i can do following, so the next up docker container can use the environment variables properly.

ENV JAVA_HOME=/usr/lib/jvm/zulu8
ENV MAVEN_HOME=/opt/apache-maven-3.6.2

But on Packer, i dont find the equivalent way to approach that.

  • environment_vars looks like only affect current build, doesnt work with runtime docker container, and i dont find a way to nest FOOvariable. $ looks like not working here.
environment_vars = [
      "FOO=hello world",
  • inline export only works with build as well. not working with the runtime container.
inline = [
      "export JAVA_HOME=/usr/lib/jvm/zulu8",
      "export MAVEN_HOME=/opt/apache-maven-3.6.2",
      "export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin", 
      "echo javahome $JAVA_HOME",
      "echo path $PATH"

Thank you.