Dockerfile: Setting multiple environment variables in single line

前端 未结 2 807
遇见更好的自我
遇见更好的自我 2021-01-31 13:32

I was under the impression that environmental variables could be set on a single line as follows so as to minimize intermediary images.

FROM alpine:3.6
ENV RUBY_         


        
2条回答
  •  無奈伤痛
    2021-01-31 13:47

    There are two formats for specifying environments. If you need single variable then you below format

    ENV X Y
    

    This will assign X as Y

    ENX X Y Z
    

    This will assign X as Y Z

    If you need to assign multiple environment variables then you use the other format

    ENV X=Y Z=A
    

    This will assign X as Y and Z as A. So your Dockerfile should be

    FROM alpine:3.6
    ENV RUBY_MAJOR=2.4 \
        RUBY_VERSION=2.4.1 \
        RUBY_DOWNLOAD_SHA256=4fc8a9992de3e90191de369270ea4b6c1b171b7941743614cc50822ddc1fe654 \
        RUBYGEMS_VERSION=2.6.12 \
        BUNDLER_VERSION=1.15.3
    
    RUN env
    

提交回复
热议问题