Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda