dockerdockerfile

Can I use env vars in Docker lables?


I don't want to repeat myself, can I do something like this?:

ENV VA1=sdfsdf \
    VAR2=dlksjdlfks \
    VAR3=1.2.3

......

LABEL VA1=ENV VA1 \
      VA2=ENV VA2 \
      VA3=ENV VA3 \

Solution

  • It should get what you are looking for:

    ENV VAR1=sdfsdf \
        VAR2=dlksjdlfks \
        VAR3=1.2.3
    ...
    LABEL VA1=$VAR1 \
          VA2=$VAR2 \
          VA3=$VAR3