How does Dockerfile reference host environment variables?

When I set the environment variable for the mirror, his value comes from the host environment variable.

2 Solutions collect form web for “How does Dockerfile reference host environment variables?”

Dockerfile build the mirror can not directly use the host environment variables, but can be achieved through the following ways

Dockerfile:

 ... ARG JAVA_HOME ENV JAVA_HOME $JAVA_HOME ... 

Build use:

 docker build --build-arg JAVA_HOME=$JAVA_HOME ... 
Heads up! This alert needs your attention, but it's not super important.