How to get exact date for docker images?

Docker

Docker Problem Overview


I run docker images and get something like this:

REPOSITORY                       TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
docker.io/postgres               latest              a7d662bede59        2 weeks ago         265.3 MB
docker.io/ubuntu                 latest              91e54dfb1179        2 weeks ago         188.3 MB

Look at CREATED column. I want to know what image created earlier with hours, minutes, seconds. Similar with containers, for command docker ps -a. How to view exact dates?

Docker Solutions


Solution 1 - Docker

Use docker inspect:

docker inspect -f '{{ .Created }}' IMAGE_OR_CONTAINER

From: https://stackoverflow.com/questions/28203413/exact-times-in-docker-ps-and-docker-images

Solution 2 - Docker

You can use the --format parameter to output CreatedAt instead of CreatedSince:

docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Size}}"

See the command line reference for more info.

Solution 3 - Docker

I think the best way would be to run docker inspect IMAGE_OR_CONTAINER, then pipe the output to grep to filter the results to what you really want.

If you only want to know when it started, run

docker inspect IMAGE_OR_CONTAINER | grep -i created

... which results in the following output:

"Created": "2015-09-18T01:46:51.471641483Z",

That's pretty clean.

... you could do the same for "started":

docker inspect IMAGE_OR_CONTAINER | grep -i started

... which results in the following output:

"StartedAt": "2015-09-18T01:46:51.79789586Z"

Solution 4 - Docker

In addition to Dag's answer, you can permanently change the format of the output from docker images by adding your custom format to your ~/.docker/config.json file:

"imagesFormat": "table {{.Repository}}\\t{{.Tag}}\\t{{.ID}}\\t{{.Size}}\\t{{.CreatedAt}}"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlex TView Question on Stackoverflow
Solution 1 - DockerwbrugatoView Answer on Stackoverflow
Solution 2 - DockerDag HøidahlView Answer on Stackoverflow
Solution 3 - DockerCalebView Answer on Stackoverflow
Solution 4 - DockerMartin CharlesworthView Answer on Stackoverflow