Badger
Badger

Reputation: 23

Dockerfile ENV var character replace

Can I do character substitution to set one ENV value based on another one?

My scenario...

ENV tableauVersion 2019-4-0
ENV tableauVersionDots 2019.4.0

ENV tabcmdURL https://downloads.tableau.com/esdalt/${tableauVersionDots}/tableau-tabcmd-${tableauVersion}_all.deb

Obviously, i'd like to be able to define tableauVersionDots based on the tableauVersion ENV variable (i.e. replace - with .)

Upvotes: 2

Views: 798

Answers (1)

David Maze
David Maze

Reputation: 159352

No. The only substitutions it's possible to do in Dockerfile ENV statements are the ones shown in the Dockerfile documentation: $variable, ${variable}, ${variable:-default}, or ${variable:+yes it is set}.

For URLs like that you don't really need them in an environment variable. If you do need to compute it and then fetch it you could do it within a single RUN statement

RUN tableauVersionDots=$(echo "$tableauVersion" | sed 's/-/./g') \
 && curl -LO https://downloads.tableau.com/esdalt/${tableauVersionDots}/tableau-tabcmd-${tableauVersion}_all.deb

The variable setting won't survive beyond this RUN statement (and in shell space I haven't even bothered to export it) but that's probably okay just for fetching a URL.

Upvotes: 1

Related Questions