Skip to content

cli/command/formatter: add CreatedAt to volume list output - #7146

Open
UditDewan wants to merge 1 commit into
docker:masterfrom
UditDewan:volume-ls-createdat
Open

cli/command/formatter: add CreatedAt to volume list output#7146
UditDewan wants to merge 1 commit into
docker:masterfrom
UditDewan:volume-ls-createdat

Conversation

@UditDewan

Copy link
Copy Markdown
  • What I did

Added a CreatedAt placeholder to docker volume ls --format, which fixes #3871.

Containers, images and networks all expose CreatedAt in their list output, but volumes did not, even though the API has returned a CreatedAt field for volumes since API v1.42. As a result, the creation time was not reachable from docker volume ls --format '{{.CreatedAt}}' or docker volume ls --format json, and consumers had to fall back to docker volume inspect per volume.

  • How I did it

Added a CreatedAt() method to volumeContext and registered the CREATED AT header, mirroring the other list formatters.

The API returns the value as an RFC3339 string, so it's parsed and rendered with time.Time.String(), matching what docker ps, docker images and docker network ls already emit for {{.CreatedAt}}. Two edge cases are handled explicitly:

  • the field is omitempty in the API, so an empty string is returned when the daemon doesn't report a creation time (rather than a zero time)
  • an unparsable value is passed through as-is rather than swallowed

The default table format is unchanged; this only adds a placeholder.

  • How to verify it
$ docker volume create foo
$ docker volume ls --format json
{"Availability":"N/A","CreatedAt":"2026-08-02 21:04:11 +0000 UTC","Driver":"local","Group":"N/A","Labels":"","Links":"N/A","Mountpoint":"/var/lib/docker/volumes/foo/_data","Name":"foo","Scope":"local","Size":"N/A","Status":"N/A"}

$ docker volume ls --format 'table {{.Name}}\t{{.CreatedAt}}'
VOLUME NAME   CREATED AT
foo           2026-08-02 21:04:11 +0000 UTC

Unit tests were extended to cover the populated, empty and unparsable cases:

$ go test ./cli/command/formatter/ -run Volume -v
  • Description for the changelog

Add a CreatedAt placeholder to the docker volume ls --format output.

  • A picture of a cute animal (not mandatory but encouraged)

🦫

Containers, images and networks all expose a "CreatedAt" placeholder in
their list output, but volumes did not, even though the API returns a
CreatedAt field for them. This made the creation time unavailable to
`docker volume ls --format`, including `--format json`.

Add a CreatedAt method to the volume context. The daemon returns the
value as an RFC3339 string, which is parsed and rendered with the same
formatting used by the other list commands, so that a template such as
`{{.CreatedAt}}` produces consistent output across commands.

The field is optional in the API, so an empty string is returned when
the daemon does not report a creation time; a value that cannot be
parsed is passed through as-is.

Fixes docker#3871

Signed-off-by: uditDewan <udit.dewan21@gmail.com>
@UditDewan
UditDewan requested review from a team and thaJeztah as code owners August 2, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Volume CreatedAt not available in JSON list output

1 participant