I use and argument (ARG
) in my Dockerfile to download a particular version of an application. I would like to tag my image with that version number. I end up writing something like that:
sh$ PHPBB_VERSION=3.2.4 &&
sudo docker build --build-arg PHPBB_VERSION=${PHPBB_VERSION} \
--tag phpbb:${PHPBB_VERSION} - < dockerfiles/bootstrap
But I don't find that very elegant since you have to type the word PHPBB_VERSION
no less than four times in this command, with all the possible errors introduced by a typo.
So, is there a more elegant solution to tag an image with the value of a Dockerfile argument?
FWIW, here is the relevant part of my Dockerfile:
sh$ cat dockerfiles/bootstrap
FROM php:7.2-cli
ARG PHPBB_VERSION
RUN echo "You are building phpBB version ${PHPBB_VERSION:?undefined}"
...
RUN wget -nv -O- \
https://github.com/phpbb/phpbb/archive/release-${PHPBB_VERSION}.tar.gz | \
tar xzf - --strip-components=1