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?
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.
You can just docker tag it with the new label. You can't duplicate it, but you also can't change the image in any way (beyond relabelling it) so it shouldn't make a difference. Docker tagging works as an effective copy You reference a new image (as listed via docker images ) with tag :1.4.
Explicitly tagging an image through the tag command. This command just creates an alias (a reference) by the name of the TARGET_IMAGE that refers to the SOURCE_IMAGE. That's all it does. It's like assigning an existing image another name to refer to it.
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.
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