Exactly as others told, shell script would help.
Just an additional case, IMHO it's worth mentioning (for someone else who stumble upon here, looking for an easier case), that is Environment replacement.
Environment variables (declared with the
ENV
statement) can also be used in certain instructions as variables to be interpreted by theDockerfile
.The
${variable_name}
syntax also supports a few of the standard bash modifiers as specified below:
${variable:-word}
indicates that ifvariable
is set then the result will be that value. Ifvariable
is not set thenword
will be the result.
${variable:+word}
indicates that ifvariable
is set thenword
will be the result, otherwise the result is the empty string.