docker / docker/cli

docker images command yields timestamps as strings that cannot be formatted

Open
#2,747 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

The docker images command passes timestamps to the --format template as strings, rather than time/date types. This means there is no way to make it print the .CreatedAt field in any format other than the default, which looks like this:

2020-09-16 20:07:21 +0200 CEST

This is inflexible and makes machine parsing of the printed output needlessly difficult.

I used this command to verify that the template is receiving a string instead of a structured type:

$ docker images --format '{{printf "%T" .CreatedAt}}'
string

This limits the utility of the --format option. If the timestamp was instead passed to the template as a structured variable, practically any format could be printed, which would make it useful for either human reading or machine parsing.

The .CreatedSince field also suffers from this problem, always yielding a string like 11 days ago. Again, it would be easier to work with if it were a native type that could be formatted according to the user's needs.

Output of docker version:

Client:
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.15.2
 Git commit:        4484c46
 Built:             Tue, 22 Sep 2020 16:21:48 +0700
 OS/Arch:           linux/arm64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.15.2
  Git commit:       4484c46
  Built:            Tue Sep 22 09:21:48 2020
  OS/Arch:          linux/arm64
  Experimental:     true
 containerd:
  Version:          19.03.13
  GitCommit:        481103c8793316c118d9f795cde18060847c370e
 runc:
  Version:          1.0.0~rc92+dfsg1
  GitCommit:        1.0.0~rc92+dfsg1-5
 docker-init:
  Version:          0.18.0
  GitCommit:        

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how docker images --format supplies .CreatedAt and .CreatedSince to Go templates. Verify the current behavior with the provided printf "%T" command, then identify the relevant CLI tests or formatting entry point. Done means both fields can be formatted as structured time values while preserving the intended output behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.