imagetools inspect --format
ignores formatting unless json
is used #1175
Open
Description
Was writing a reply to docker/hub-feedback#2043, and noticed this.
Reproduced on;
docker buildx version
github.com/docker/buildx v0.8.2-docker 6224def4dd2c3d347eee19db595348c50d7cb491
When using the -f
/ --format
option, the template is ignored, unless it's using the json
function;
docker buildx imagetools inspect --format '{{.Manifest.Digest}}' tensorflow/tensorflow:1.13.1-gpu-py3
Name: docker.io/tensorflow/tensorflow:1.13.1-gpu-py3
MediaType: application/vnd.docker.distribution.manifest.v2+json
Digest: sha256:0f949ccc690d9c50e9b46b16d9030c2c6845af621c2e7e82c4bf59803edc69b5
docker buildx imagetools inspect --format '{{json .Manifest.Digest}}' tensorflow/tensorflow:1.13.1-gpu-py3
"sha256:0f949ccc690d9c50e9b46b16d9030c2c6845af621c2e7e82c4bf59803edc69b5"
This is inconsistent with other commands, for example, here's docker image inspect
(difference between using json
and without is that the json
output uses JSON quoting for the output);
docker image inspect -f '{{.ID}}' busybox
sha256:62aedd01bd8520c43d06b09f7a0f67ba9720bdc04631a8242c65ea995f3ecac8
docker image inspect -f '{{json .ID}}' busybox
"sha256:62aedd01bd8520c43d06b09f7a0f67ba9720bdc04631a8242c65ea995f3ecac8"
Also note that the json
output does not print a newline at the end, which can make it a bit cumbersome to use; here's the full output (notice that the prompt is appended to the output, because there's no trailing newline)
root@swarm-test-01:~# docker buildx imagetools inspect --format '{{json .Manifest.Digest}}' tensorflow/tensorflow:1.13.1-gpu-py3
"sha256:0f949ccc690d9c50e9b46b16d9030c2c6845af621c2e7e82c4bf59803edc69b5"root@swarm-test-01:~#