Closed italktothewind closed 4 years ago
If you want to healthcheck RESTHeart then you can call the /ping
URI. I don't see why you should want to check the container health from within the container itself, it's not a good practice. If you instead meant to check the health of another container, then it's not a good practice either, you should monitor containers with an external monitoring system.
If I misunderstood what you mean please be more specific in your request.
I have the following problem. I have this docker compose:
version: '3.4'
services:
mongodb:
image: mongo:4.2
ports:
- 27017:27017
restheart:
image: softinstigate/restheart:3.10.0
ports:
- 8082:8080
volumes:
- ./restheart:/opt/restheart/etc:ro
depends_on:
- mongodb
healthcheck:
test: ["NONE"]
I want to put a healthcheck in restheart (instead of NONE), but all the commands I tried failed. Then I tried to execute something like curl using docker exec, but I got:
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"curl\": executable file not found in $PATH": unknown
From the dockerfile:
FROM openjdk:8u111-jre-alpine
RUN apk upgrade --update && apk add --update libstdc++ curl ca-certificates bash
...
seems that curl is already installed, but I can't acces it.
I see what you mean.
I don't really know why the container does not find curl, it's RESTHeart version 3 and I'm not using it since a lot. The curl command should be installed under /usr/bin/curl
(it was Alpine Linux), then maybe try providing the healthcheck with the absolute path to curl.
I will give it a try...
I checked the branch and RESTHeart 3.10 was not based on Alpine Linux but already on gcr.io/distroless/java:8
so there's literally nothing installed on it, not even the sh
shell. It's a distribution radically focused on security. See https://github.com/GoogleContainerTools/distroless.
Dockerfile: https://github.com/SoftInstigate/restheart/blob/3.10.0/Dockerfile
Unfortunately the only option is to build your own image of RESTHeart, using a different base image. You can refer to previous versions, when we were still using Alpine.
It's a pity to build images that are a pain in the neck for the devs. Even for very standard stuff, like adding a healthcheck. A lot of products have different images, for example RabbitMQ has an official image for development (including a webserver with an UI) and another image for production. Of course I can do it by myself, but it's not the same, I'm just using restheart for integration tests. Thanks for the information, I will try to use an older version, hope it works with mongo 4.2.
Previous version, 3.9.0, is not distroless and works fine. I fix it downgrading it. Thanks for your help.
@italktothewind This is an open source project mostly developed by a couple of persons in their spare time, it's not sponsored by a big company. If you want contribute we are always open to accept PRs. Take care.
Please, have a look at RESTHeart 5.0.1 release notes.
GREAT NEWS :-)
Currently it's impossible to do a healthcheck in the Restheart container because you can't execute something like a curl. Please provide some method to check the container's health.