Home > Backend Development > Golang > How to Access Docker Image Labels with Dots in Their Names?

How to Access Docker Image Labels with Dots in Their Names?

Mary-Kate Olsen
Release: 2024-11-09 07:08:02
Original
868 people have browsed it

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
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template