Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

256
Views
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'
about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

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'
about 4 years ago · Santiago Trujillo Report

0

why not :

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

this will eliminate the needs of another tool.

about 4 years ago · Santiago Trujillo Report

0

The above answer is close but needs to add a bracket to work correctly.

jq '."22/tcp"[].HostPort'

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!