Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command line templating in Dockerfiles

I am trying to build a Dockerfile that builds my project for multiple base images (e.g., Ubuntu 17.10 for multiple architectures)

I want to be able to write something like

FROM {{ ARCH }}/ubuntu:17.10
...

And have it resolve at build time to ubuntu:17.10 or ppc64le/ubuntu:17.10. Is there someway to do this?

Additionally a separate solution might be to have two docker files, but somehow include the common portions of the file into both the docker files.

like image 499
ssb Avatar asked Sep 17 '26 13:09

ssb


1 Answers

You can use a build argument and use docker build --build-arg foo=bar to build the image.

like image 82
Mano Marks Avatar answered Sep 20 '26 11:09

Mano Marks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!