Home >Backend Development >Golang >How to Access Docker Image Labels with Dots in Their Names?
Accessing Docker Image Labels with Dots in Their Names
The docker inspect command provides a versatile means to retrieve information about Docker images, including their labels. However, accessing labels with dots in their names can present a challenge.
Using Basic Notation
For plain label names, the --format option with Go templates allows for straightforward label retrieval:
$ docker build -t foo . $ docker inspect -f '{{ .Config.Labels.foo }}' foo bar
Accessing Labels with Dots
To access labels with dots, the Go template syntax falls short. However, the index function within a template can be employed:
$ docker inspect -f '{{ index .Config.Labels "com.wherever.foo" }}' foo bang
The above is the detailed content of How to Access Docker Image Labels with Dots in Their Names?. For more information, please follow other related articles on the PHP Chinese website!