Docker always checks if the local image is the same or lower version than the official Docker Hub repository?

2

When raising a new application, you do not have the image locally, so Docker will get the image that is the base of the container. Once the image has been downloaded, Docker goes up the container. The application is there running. But if there is locally the image that was base for another container, if it is old, how does Docker handle this part when lifting the new application? Take the old image, update and run the new container? I would like to understand this whole process.

    
asked by anonymous 03.05.2018 / 16:12

1 answer

2

Let's start with the run command. When running docker run ubuntu docker will check for locally an image of ubuntu using the :latest tag. If there is a docker you will create a container using this image, otherwise it will hold the docker pull ubuntu:latest and then create the container.

When running the command docker pull ubuntu it will check if there is an image of ubuntu with the tag :latest , otherwise it will download the image. If you run docker pull it finds a local image with the :latest tag then it will download the image's signature (a hash in sha256) that is in DockerHub and will compare with the signature of your local image, if they are same it prints on the console something like:

status: Image is up to date for ubuntu:latest

If they are different it will download the new image and mark the old one with the tag <none> , something like this:

Repository            tag                 Image ID            CREATED             SIZE
ubuntu               latest              113a43faa138        2 weeks ago         81.2MB
ubuntu               <none>              452a96d81c30        7 weeks ago         79.6MB
    
21.06.2018 / 06:54