How to get exact date for docker images?

后端 未结 4 1227
轻奢々
轻奢々 2021-02-02 05:15

I run docker images and get something like this:

REPOSITORY                       TAG                 IMAGE ID            CREATED             VIRTUA         


        
相关标签:
4条回答
  • 2021-02-02 05:57

    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.

    0 讨论(0)
  • 2021-02-02 06:03

    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"
    
    0 讨论(0)
  • 2021-02-02 06:11

    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}}"
    
    0 讨论(0)
  • 2021-02-02 06:18

    Use docker inspect:

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

    From: Exact times in "docker ps" and "docker images"

    0 讨论(0)
提交回复
热议问题