search

Home  >  Q&A  >  body text

Dockerfile如何引用宿主机的环境变量啊?

我在设置镜像的环境变量的时候,他的值从宿主机的环境变量来。

高洛峰高洛峰2774 days ago1164

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-24 16:03:05

    Dockerfile cannot directly use the host’s environment variables when building the image, but it can be achieved in the following ways

    Dockerfile:

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

    Build using:

    docker build --build-arg JAVA_HOME=$JAVA_HOME ...

    reply
    0
  • 高洛峰

    高洛峰2017-04-24 16:03:05

    http://stackoverflow.com/ques...

    reply
    0
  • Cancelreply