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
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3