James
James

Reputation: 1055

Tagging docker image with multiple tags

Is it possible to ensuring that only a single docker image is created with multiple tags and how do I get these tags to appear in the Docker repository(JFrog) after a docker push command?

A Related question I used to add multiple tags at once on build: https://stackoverflow.com/a/35565384/3762850

My bash script:

#!/bin/bash

target_image="<my-remote-site>:8081/<docker-artifactory>/<repository-key>"

tag_a="First-Tag"
tag_b="Second-Tag"

sudo docker login -u <user-name>-p <user-password> <my-remote-site>:8081
sudo docker build -t "${target_image}:${tag_a}" -t "${target_image}:${tag_b}" .
sudo docker push "${target_image}:${tag_a}" "${target_image}:${tag_b}"

Upvotes: 1

Views: 9481

Answers (1)

prisar
prisar

Reputation: 3195

docker tag helps to put tags to an image. It can be used to create a new tag with a previous tag.

#!/bin/bash

target_image="<my-remote-site>:8081/<docker-artifactory>/<repository-key>"

tag_a="First-Tag"
tag_b="Second-Tag"

sudo docker login -u <user-name>-p <user-password> <my-remote-site>:8081
sudo docker build -t "${target_image}:${tag_a}" .
sudo docker tag "${target_image}:${tag_a}" "${target_image}:${tag_b}"
sudo docker push "${target_image}:${tag_a}" "${target_image}:${tag_b}"

Upvotes: 3

Related Questions