I have to execute the same script to two docker
images.
My Dockerfile
are:
FROM centos:6
...
and
FROM centos:7
...
Is it possibile to have a single file and pass a parameter, something like:
FROM centos:MYPARAMS
and during the build somethings like that:
docker build --no-cache MYPARAMS=6 .
Thank you
Just to put this in right context, it is now (since May 2017) possible to achieve this with pure docker since 17.05 (https://github.com/moby/moby/pull/31352)
Dockerfile should look like (yes, commands in this order):
ARG APP_VERSION
ARG GIT_VERSION
FROM app:$APP_VERSION-$GIT_VERSION
Then build is invoked with
docker build --build-arg APP_VERSION=1 --build-arg GIT_VERSION=c351dae2 .
Docker will try to base the build on image app:1-c351dae2
Helped me immensely to reduce logic around building images.
From my knowledge, this is not possible with Docker.
The alternative solution is to use a Dockerfile "template", and then parse it using the template library of your choice. (Or even using sed
command)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With