I configure psFormat
on ~/.docker/config.json
like this:
{
"psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.CreatedAt}}\\t{{.Status}}\\t{{.Ports}}\\t{{.Names}}"
}
The problem is CreatedAt
column show exact date instead of how long the container was created:
CREATED AT
2023-05-21 04:26:47 +0700 +07
But what I want is:
CREATED
About a minute ago
The documentation does not tell how to display in this format.
I made the same mistake,
instead of using the column Created
, you're looking for RunningFor
, here's an example using --format
, but it'll work too in config.json
:
docker ps --format "table {{.Names}}\t{{.RunningFor}}\t{{.Status}}\t{{.Image}}\t{{.Ports}}"
See the documentation (which does not give great details about the format, I know you read it, but it lists alternative columns you can try): https://docs.docker.com/engine/reference/commandline/ps/#format
Valid placeholders for the Go template are listed below:
Placeholder
Description
.CreatedAt
Time when the container was created..RunningFor
Elapsed time since the container was started.