okay..till now we have pulled some official images.
Carefully look at the nginx image : nginx which has a tag: latest & image id de2543b9436b.
You can see this from the official docker hub: https://hub.docker.com/_/nginx
Here "mainline" , "latest", "1.21" etc means all the same.
In our system, we have nginx image with latest tag.
Lets pull a nginx image with mainline tag
If you go to docker hub, you can see this :
While we pulled the nginx:mainline, you can see that few layers were already existed and others were pulled. SO, that is the benefit of having an image .
We previously had nginx image and thus few layers where existed. Now, as we pulled mainline tag, we just had to pull few layers.
now lets check the images
Check the mainline tag & latest tag has the same size 142mb.
Now lets create an image in docker hub using an official image
docker image tag <image to copy> <targeted image to be created>
tag is used to use the newest tag of that image of copy.
Oh! Before that, log in into your system using docker hub. SO that you can create an image and push it to docker hub.
docker login
then give your username & password.
Now, lets create our image
we have also checked our newly created image.
As our image will not be an official image, thus we have used "user_name/image name" format.
Check carefully, nginx & mitul3737/nginx image has the same image ID: de2543b9436b
also they have the same tag : latest
This is because mitul3737/nginx has just copied nginx image and we told it to set the same tag (latest)
now, lets push it to our dockerhub profile
docker image push < your image>
You can see that the docker hub has this one
It has the latest tag with it.
Now, lets change the tag and of our image add another layer over it.
docker image tag <image to copy> <image where to copy>:<your_tag>
We have copied our mitul3737/nginx image and used it to create another image with tag "testing"
YOu can see the nginx, mitul3737/nginx al has same image ID but mitul3737/nginx has latest & testing tag. These means that , they are all same image. Just copy of them with different names.
Now, lets push it to our docker hub
Look carefully, the layers exists . This means that they are not re uploaded. while copying from mitul3737/nginx to mitul3737/nginx:testing, we copied everything and just gave it a new tag . Thus no new layers were added and we had nothing to uploadd.
In the docker hub:
YOu can see that, under the mitul3737/nginx image, the layers are added. So, you can use latest one using mitul3737/nginx:latest command and use the testing one using
mitul3737/ngnx:testing
Top comments (0)