Home > Article > Backend Development > How to Access Docker Image Labels with Periods in Their Names?
Accessing Docker Image Labels with Periods in Names
Docker's docker inspect command provides a means to retrieve labels associated with Docker images. However, accessing labels with periods (".") in their names using the --format option poses a challenge.
To bypass the limitations of the --format option, the index function offers a solution. This function allows users to retrieve values from a map-like structure based on a specified key.
In the bash script, the following syntax can be utilized:
docker inspect -f '{{ index .Config.Labels "com.wherever.foo" }}' <image-name>
This command will return the value associated with the label "com.wherever.foo" from the JSON output of the docker inspect command.
The above is the detailed content of How to Access Docker Image Labels with Periods in Their Names?. For more information, please follow other related articles on the PHP Chinese website!