Docker Community Forums

Share and learn in the Docker community.

How to show "time elapsed since created" with `docker ps --format "..."`?


(Grisaitis) #1

I’d like to reformat docker ps so that it only shows columns for “name”, “status” and “created” as those appear by default with docker ps.

The issue is, when I do

$ docker ps --format “{{.Name}}\t{{.Status}}\t{{.CreatedAt}}”

I get a long timestamp for the “CREATED” column.

How can I get something like “X days ago”?

(Grisaitis) #2

Just figured it out.

I needed to use the “RunningFor” field, which says how long ago the container was created.


$ docker ps --format “table {{.Names}}\t{{.Status}}\t{{.RunningFor}} ago”