I have a Docker network with a field that I want to query with docker inspect --format '{{...}}'
:
[
{
"Name": "bridge",
// ...
"Options": {
// ...
"com.docker.network.bridge.name": "docker0"
}
}
]
Because period is used as a delimiter in the --format
expression, how can I reference the field above? I can't just say {{.Options.com.docker.network.bridge.name}}
CodePudding user response:
You can use index
:
{{index .Options "com.docker.network.bridge.name"}}
This functionality comes from the upstream text/template library.