Docker inspect: Select field that has forward slash using jq

# 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'

  • Is Spring Boot Logging to System Out in Docker on AWS a memory leak?
  • Docker rsyslog driver add message length before actual message
  • docker port mapping error
  • Cluster takes a few minutes to service requests when node goes down
  • Running MariaDB in a docker container using docker stack
  • NetfilterQueue not working in a docker container
  • Using Spinnaker to deploy a Docker image from dockerhub to Aws Eb
  • Docker for windows - Internal server error
  • rg.apache.spark.SparkException: Invalid master URL: spark://tasks.501393358-spark-master:7077
  • Where is the Docker daemon log?
  • In Docker, “Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on different interfaces”
  • “debconf: delaying package configuration, since apt-utils is not installed” :> google notebooks bash error
  • 2 Solutions collect form web for “Docker inspect: Select field that has forward slash using jq”

    why not :

    docker inspect  --format '{{ (index (index .NetworkSettings.Ports "22/tcp") 0).HostPort }}' blah
    

    this will eliminate the needs of another tool.

    jq supports double quotes for keys with special characters:

    jq '."22/tcp".HostPort'
    

    edit: this is mentioned in the docs, which also mention that you can add brackets to help with readability, if you want:

    jq '.["22/tcp"].HostPort'
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.