Search code examples
dockerdockerfiledocker-desktop

Why does Docker Desktop show "Newer image available"?


I am building a Docker image with the following base image in the Dockerfile:

FROM python:3.12-slim-bookworm

My build command is docker build . --no-cache=true. The build logs are:

[+] Building 78.3s (17/17) FINISHED                                                                                                                                                  docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                 0.0s
 => => transferring dockerfile: 741B                                                                                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/python:3.12-slim-bookworm                                                                                                                         1.8s
 => [auth] library/python:pull token for registry-1.docker.io                                                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                                                                                    0.0s
 => => transferring context: 1.80kB                                                                                                                                                                  0.0s
 => [ 1/10] FROM docker.io/library/python:3.12-slim-bookworm@sha256:eb53cb99a609b86da6e239b16e1f2aed5e10cfbc538671fc4631093a00f133f2 
...

After the image is built, Docker Desktop shows that it is built with the base image FROM python:3-slim, and that python:3-slim has a newer image available, as shown in my screenshot.

According to this answer https://stackoverflow.com/a/74141798/23361424, since the build command includes --no-cache=true, it should pull the newest available image.

However, the sha256 digest from the build logs eb53cb99a609b86da6e239b16e1f2aed5e10cfbc538671fc4631093a00f133f2 and the digest from the latest (as of today) python:3-slim image https://hub.docker.com/layers/library/python/3-slim/images/sha256-4e7d6f2672bd4a834eac99973679c7e73fbcd475d439b7569512bf478ed39c78?context=explore are different.


Solution

  • I solved the problem with this build command: docker build . --no-cache.

    The official documentation for docker build and its options is here: https://docs.docker.com/engine/reference/commandline/image_build/#options

    Apparently docker build . --no-cache=true uses the cache.