问题
Docker Hub builds a Syncthing image for me from this source repo.
I tagged the latest commit v0.13.5, but Docker built it twice: once for latest and once for v0.13.5.
Why? Shouldn't it be able to figure out the source is the same? Am I just doing something dumb in my Dockerfile, breaking caching? Is there some way I need to hint to Docker Hub that this should really be two images with the same checksum but different tags?
I'm thinking of the two Docker image tags latest
and v0.13.5
like two git tags both pointing to the same commit. Shouldn't Docker Hub work that way too? If someone tries to pull latest
they'd pull exactly the same image tagged v0.13.5
? I know how to pull/re-tag/push, but again, seems like there just must be some way to get Docker Hub to do this automatically.
Build settings:
回答1:
Latest
is just “the last build/tag that ran without a specific tag/version specified”.
If you push a tagged image it does not replace the current image tagged with latest. If you push tagged images only, latest
tag is not added.
Automated Builds on Docker Hub is adding the latest
tag automatically for the master branch.
回答2:
With a little magic, Docker Hub can do this! Pablo Chico de Guzmán helped me out.
Steps:
- add a file called
hooks/post_push
- make
hooks/post_push
executable, commit and push - delete the "Branch" build, but leave the "Tag" build in place
Now, any tags I push (e.g. git push --tags
) fire off an automated build, and the same image is also given the latest
tag.
Here's the change I had to make so the most recent "vX.Y"-tagged meonkeys/syncthing
image is also tagged latest
.
来源:https://stackoverflow.com/questions/37650119/how-do-i-make-a-docker-hub-use-the-same-image-for-latest-and-vx-y