How to tag an image in a Dockerfile?

37,795

Unfortunately it is not possible. You can use build.sh script, which contains like this:

#!/usr/bin/env bash
if [ $# -eq 0 ]
  then
    tag='latest'
  else
    tag=$1
fi

docker build -t project:$tag .

Run ./build.sh for creating image project:latest or run ./build.sh your_tag to specify image tag.

Share:
37,795
Jérôme Verstrynge
Author by

Jérôme Verstrynge

You can contact me via my LinkedIn profile.

Updated on July 09, 2022

Comments

  • Jérôme Verstrynge
    Jérôme Verstrynge almost 2 years

    I have been digging the documentation, but I did not find an instruction to define the tag name of an image in a Dockerfile. There is one available for the command line though.

    Say I create an image FROM another image, I don't want it to bear the same name. How should I proceed?