Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a Docker image based on a git tag in the public Registry?

I'm building a continuous deployment strategy using Docker. My code is hosted on Github, and the Docker registry starts an automated build when I push to git. The default setting is to start building when I push to master, and create an image with the "latest" tag. This is fine, but I want to also be able to tag commits in git and create an image based on that. There seems to be some functionality for that on the Docker registry site, on the Edit Automated Build settings page I can select "tag" for type and provide a static tag name.

How can I have the Docker tag name be the same as the Git tag name?

The goal is to be able to tag specific versions so there is a version history.

like image 204
remmelt Avatar asked Oct 20 '14 08:10

remmelt


1 Answers

Most simple solution from the command line is a nested git-rev command:

docker tag <image> <image>:$(git rev-parse --short HEAD)"

gives you e.g.

<image> = myImage >> myImage:67df348
like image 154
Flowkap Avatar answered Oct 07 '22 01:10

Flowkap