Internal variables in Dockerfiles

Is there a way to use variables inside of a Dockerfile? I’m not talking about setting system variables for the container, but rather using variables within the Dockerfile itself.

For example, if the version of software I was downloading and installing changed a lot, it would be nice to do something like:

        FROM centos:centos6
        # Install Software and remove RPM
        RUN wget$SOFTWARE_VERSION.rpm
        RUN rpm ivh $SOFTWARE_VERSION.rpm
        RUN rm -rf $SOFWARE_VERSION.rpm

Is something like this possible? Or has it been considered?

yes :smile:
you want ENV SOFTWARE_VERSION testPackage-1.0

and Docker 1.3.1 - as it processes those when it runs each build step.


1 Like

Thank you very much Sven!

I believe ARG is what you’re looking for: