Skip to content

Commit a044b95

Browse files
another label printing technique that avoids jq
Learned a bit more about Go templates and found this solution that can print the version without having jq installed
1 parent b9e0658 commit a044b95

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

docs/src/image-version.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ For docker and podman, the `inspect` command returns JSON with all of the image
1414
The `jq` program just helps us parse this JSON for the specific label we are looking for,
1515
but you could just scroll through the output.
1616
```bash
17-
docker inspect ldmx/dev:latest |\
18-
jq 'map(.Config.Labels["org.opencontainers.image.version"])[]'
17+
docker inspect ldmx/dev:latest \
18+
| jq 'map(.Config.Labels["org.opencontainers.image.version"])[]'
19+
```
20+
You can also avoid using `jq` and scrolling if you provide a Go template.
21+
```bash
22+
docker inspect ldmx/dev:latest \
23+
--format '{{ (index .Config.Labels "org.opencontainers.image.version") }}'
1924
```
2025

2126
### Apptainer

0 commit comments

Comments
 (0)