Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

265
Vistas
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'
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

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'
over 4 years ago · Santiago Trujillo Denunciar

0

why not :

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

this will eliminate the needs of another tool.

over 4 years ago · Santiago Trujillo Denunciar

0

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

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

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda