Docker Tags Pull and Push

I have a question Regarding Docker Tags,

Scenario -

I am pushing docker image to docker hub without assigning tag, and it is getting stored in docker hub repo with latest tag which is expected behavior, but when I am doing the same thing again, rather than overwriting it, it is getting pushed with Tag 1.0, leaving two images on Docker Hub Repo one with Latest Tag and another with 1.0 tag.

Q1 Is above scenario expected or there is something wrong in my doing, if somebody can explain and please route me through detailed link.

Q2. When I pull image from docker hub repo and I am not using tag in command for example - docker pull “RepoName/imagename”. It is always downloading images with latest tag, not the actual latest image which has 1.0 tag, so my question is, how do I always pull actual latest image which is updated recently by default without actually assigning tag name/no.

Sunil

Short answer: This is not possible. Long answer: via api it would be possible but I don’t think that’s what you want.

It sounds like what you want is, is to always push the same tag. Just build with docker build -t yourimage:latest and push yourimage:latest and latest always points to your current image.

This is at least not documented at Manage repositories | Docker Docs

Yes if you define no tag it’ll always use the latest tag. The latest tag must not point to the image most recently build.

Thanks a lot for your help, Let me explain:

We are trying to deploy Docker image from Docker hub to Open Shift [Locally Installed].

Scenario 1

We are trying to build and push Docker image while overwriting with latest tag Always.

docker push RepoName/ImageName:latest

Now, when I deploy this image first time in open shift, it works perfectly fine.

But how do I deploy changed [overwritten with same tag] image in OpenShift?

When I click on deploy in deployment section in openshift, it builds with same previous image NOT with new /changed/ overwritten image that came in second build.

Scenario 2

We have created project in open shift and deployed first image with :latest tag that works fine.

If we configure some versioning mechanism and build second image, let’s say with increment no. in tag - docker push RepoName/ImageName:{1}

How do I deploy this new image [with new tag] to OpenShift?

When I click on deploy in deployment section in openshift, it builds with image with having latest tag NOT with new /changed {1} tag that came in second build.