# docker inspect blah | jq '.[] | .NetworkSettings.Ports'
{
"22/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "32776"
}
]
}
How the heck do I get the HostPort value? I tried the following but that failed.
# docker inspect blah | jq '.[] | .NetworkSettings.Ports.22\/tcp.HostPort'
why not :
docker inspect --format '{{ (index (index .NetworkSettings.Ports "22/tcp") 0).HostPort }}' blah
this will eliminate the needs of another tool.
The above answer is close but needs to add a bracket to work correctly.
jq '."22/tcp"[].HostPort'