Search code examples
docker

What is the created time in docker images command?


What is the CREATED time exactly when you give this command?

docker images enter image description here

It gives the time like "3 months ago", or "9 days ago".

Is it the time it was uploaded to docker hub?

Even for the locally created images, it shows like "15 minutes ago", while I had created it just a minute ago.


Solution

  • It should be the date of the latest docker build run by the image owner, as defined in the image/image.go file, which can be found in the container once the image has been run.

    You can inspect low-level image info to see its exact value with:

    docker inspect -f '{{.Created}}' hello-world
    

    where 'hello-world' is the name of your image.

    If you are in a VM, the timestamp might not be precise for local images, as your VM clock might not be precisely synchronized (by typing 'date', I see mine is synchronized, but on UTC: one-hour shift).


    As noted by Grigory Kislin in the comments, you can also specify the createdDate (or any timestamp metadata) when building images with the Spring Boot build plugins (Maven or Gradle)

    BMitch adds in the comments:

    The field is fairly easy to change.
    It's the created field in the image config which is part of an OCI image (the same exists for Docker images).

    Some tools leave it unset or use a predictable value for reproducibility, cached builds will return the previous value, and otherwise tools will often set it to the build time.