PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 28, 2022

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

 September 28, 2022     continuous-deployment, docker, git, github     No comments   

Issue

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.


Solution

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


Answered By - Flowkap
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing