Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List labels for a docker container
docker inspect -f '{{ range $k, $v := .ContainerConfig.Labels -}}
{{ $k }}={{ $v }}
{{ end -}}' $cid
@jmartens
Copy link

To imrpove readbility and easier spot empty labels I would add a semicolon after {{ $k }}={{ $v }}:

docker inspect -f '{{ range $k, $v := .Config.Labels -}}
{{ $k }}={{ $v }};
{{ end -}}' $cid

@jmartens
Copy link

jmartens commented Oct 19, 2022

Or if you don't mind json output: docker inspect -f "{{json .Config.Labels}}" $cid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment