Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURL and WGET missing from current container #3371

Closed
dvasdekis opened this issue Nov 18, 2019 · 11 comments · May be fixed by sumodgeorge/graphql-engine#30, Allymahmoud/graphql-engine#386 or ptakpatryk/graphql-engine#27

Comments

@dvasdekis
Copy link

Hey folks. It looks like both curl and wget are missing from the current container? Neither are in /bin , and additionally I get:

docker exec -it local_env_ib-gateway9_1 wget
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"wget\": executable file not found in $PATH": unknown
docker exec -it local_env_ib-gateway9_1 curl
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"curl\": executable file not found in $PATH": unknown

Any idea where they've gone? They're a prerequisite for the health checks described here.

@shahidhk
Copy link
Member

@dvasdekis Health checks are typically done from outside the container. We do not package curl or wget in the interest of keeping the image size lean.

Can you give more hints on your use case?

@lexi-lambda
Copy link
Contributor

My guess is that @dvasdekis is interested in using the Docker built-in HEALTHCHECK feature, which unfortunately only supports running commands inside the container.

That said, I’m not actually that familiar with HEALTHCHECK, since in all deployments of Docker I’ve used, the load balancer had some external mechanism for checking health, as you allude to. I don’t know what systems actually consume the built-in HEALTHCHECK information (maybe Docker Swarm…?), so I’d also like to know more details about the use case.

@dvasdekis
Copy link
Author

dvasdekis commented Nov 18, 2019

Correct @lexi-lambda - I'm personally using Docker-Compose, and in order to bring the containers up in the right order and ensure that they're available, the container has to be able to run a command that reports its health. In my case, I want this healthcheck to only be successful after the migrations have finished running. A command might be curl -H "content-type: application/json" -X POST --data 'query { tbl_myschema_version { version_id } }' http://localhost:8080/v1/graphql || exit 1, where tbl_myschema_version is written to as the last step in the migrations process.

@shahidhk
Copy link
Member

Looks like docker-compose recommends running a command inside the container to do health checks [ref].

@dvasdekis I just checked the latest image and wget seems to be present at /bin/wget.

What version are you on?

@dvasdekis
Copy link
Author

I see it too now. I must have been on an old version. I'm so sorry, not sure why it didn't appear when I looked in the container I was running!
Thank you!!

@dvasdekis
Copy link
Author

dvasdekis commented Nov 19, 2019

For those looking to use wget to perform GraphQL requests, the syntax is:
wget --header 'content-type: application/json' --post-data='{ "query": "{ tbl_hedgecheap_version { version_id } }" }' -q -O - http://localhost:8080/v1/graphql.

@Toub
Copy link

Toub commented Nov 5, 2020

For those interested, you can also use hasura /healthz api as docker healthcheck:

    healthcheck:
      test:  wget --no-verbose --tries=1 --spider http://0.0.0.0:8080/healthz || exit 1
      interval: 5s
      timeout: 5s
      retries: 5

Related links:

@davidpanic
Copy link

curl and wget also seem to be missing in v2.0.0-alpha.2
image

Is there another way of doing health checks in docker compose? Relying on containers having curl available seems kind of dumb...

@davidpanic
Copy link

If anyone is still wanting to do hasura healthchecks with docker-compose, I've found an alternate solution using bash and commands that are available pretty much anywhere:

healthcheck:
  test: ["CMD", "bash", "-c", "exec 5<>/dev/tcp/127.0.0.1/8080 && echo -e 'GET /healthz HTTP/1.1\n\n' >&5 && cat <&5 | head -n 1 | grep 200"]
  interval: 5s
  timeout: 5s
  retries: 3

@m-rgba
Copy link
Contributor

m-rgba commented Mar 20, 2022

Slightly more intensive, but I've seen this done as well.
Pretty much adding curl during the first healthcheck without having to use a custom dockerfile. Going to have a slight amount of overhead on each check though.

healthcheck:
  test: ["CMD-SHELL", "apt-get update -y && apt-get install -y curl && curl --fail http://localhost:8080/healthz || exit 1"]
  interval: 5s
  timeout: 3s
  retries: 5

@ajayvignesh01
Copy link

Slightly more intensive, but I've seen this done as well. Pretty much adding curl during the first healthcheck without having to use a custom dockerfile. Going to have a slight amount of overhead on each check though.

healthcheck:
  test: ["CMD-SHELL", "apt-get update -y && apt-get install -y curl && curl --fail http://localhost:8080/healthz || exit 1"]
  interval: 5s
  timeout: 3s
  retries: 5

Or instead of doing that every time, you could just add installing curl to your Dockerfile to only install during build
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment