docker ps
and docker images
express times in a rather vague fashion, e.g. "About an hour ago" or "2 days ago". How can I discover the exact times?
There is no difference between the docker ps (docker process status) and docker container ls (docker container list) commands in terms of functionality. They even allow the same set of flags. The only real difference between the two is the fact that the latter is newer and more verbose than the former.
ps means “Process Status”, so docker ps basically shows all of the Docker processes actively running. docker ps lists all containers that are up and running.
An image can never change. So, if you get your Docker virtual machine into a working state and create an image, you know that image will always work, forever. This makes it easy to try out additions to your environment. You might experiment with new software packages, or try to reorganize your project files.
Docker containers always use the system clock of the host machine but it sets its time-zone as UTC.
Use docker inspect
:
docker inspect -f '{{ .Created }}' IMAGE_OR_CONTAINER
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With