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

419
Visualizações
How to use httpie and jq within docker?

How to use httpid and jq within docker?

I want to get the ip only in json result like '34.10.12.40'

docker run -it --rm blacktop/httpie -b ifconfig.co/json
{
    "country": "United States",
    "country_eu": false,
    "country_iso": "US",
    "hostname": "lqwtx.com",
    "ip": "34.10.12.40",
    "ip_decimal": 39585,
    "latitude": 35,
    "longitude": 105
}

but I've tried some ways but does not work, like blow.

docker run -it --rm blacktop/httpie ash -c "http -b ifconfig.co/json | jq '.ip’”

docker run -it --rm blacktop/httpie -b ifconfig.co/json jq '.ip'
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This is the dockerfile of the image you used, see this:

FROM alpine:latest

RUN apk add --no-cache jq httpie

ENTRYPOINT [ "http" ]
CMD [ "--help" ]

From above, you can see it set an entrypoint with http for this image, so all your command used in docker run will be act as parameters for http, so of course you will fail.

Next is a method for you to make use of it:

docker run -it --rm --entrypoint=/bin/sh blacktop/httpie -c "http -b ifconfig.co/json | jq '.ip'"

Sample output:

"92.121.64.197"

Above command will override the default entrypoint with /bin/sh, then you can use jq to parse output of httpie in pipeline.

over 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