'How do I use Docker --format when the key contains a period?
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}}
Solution 1:[1]
You can use index:
{{index .Options "com.docker.network.bridge.name"}}
This functionality comes from the upstream text/template library.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BMitch |
