Skip to content

Instantly share code, notes, and snippets.

@steve-jansen
Created August 19, 2016 01:55
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
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