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

The question is asking how to display the exact times when using docker ps and docker images. This can be accomplished directly with a format argument, using CreatedAt

$ docker ps --format 'table {{.ID}}\t{{.Command}}\t{{.CreatedAt}}'
CONTAINER ID        COMMAND                  CREATED AT
86baa3a5058a        "./env.sh catalina.s…"   2019-10-30 08:30:15 -0400 EDT   
1eb21e95119d        "./env.sh catalina.s…"   2019-10-30 06:58:34 -0400 EDT   
87be4be4c328        "docker-entrypoint.s…"   2019-10-30 06:58:33 -0400 EDT   
e4ab699631c8        "./env.sh catalina.s…"   2019-10-30 06:58:32 -0400 EDT   

The table specification adds the headers. The legal format fields are documented, for example at https://docs.docker.com/engine/reference/commandline/ps/#formatting, but mostly correspond to the capitalized column headers, so you could add {{.Ports}} to the format above.

docker inspect (from this answer https://stackoverflow.com/a/28203469/500902) can be used to display the time for a single image or container, uses a different format property {{.Created}} and displays the time format slightly differently, for no obvious reason.


Use docker inspect:

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

Tags:

Docker