We had a similar requirement and a relatively simple script came up that does just that:
We create a file called dockerfile_template , in which we use the variables in the same way as you describe. the script accepts this file, performs string replacements, and copies it to dockerfile (no _template) before calling docker build dockerfile .
It works very well. Also very expandable for future needs.
Update :
Drop it. Use build-arg ( here )
source share