influxdata / influxdata/influxdb

Consider adding a HEALTHCHECK instruction to Dockerfile

Open
#24,280 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Proposal:__
Add a HEALTHCHECK instruction to Dockerfile

See https://docs.docker.com/engine/reference/builder/#healthcheck

e.g.

```
HEALTHCHECK --interval=5s --timeout=10s --retries=5 CMD [ "curl", "http://localhost:8086/health" ]
```

__Current behavior:__
When influxdb is brought up in a container, services which depend on it (like telegraf) won't start properly until influxdb is fully up and accepting connections. So to use docker compose as an example, we need this:

```
services:
telegraf:
image: telegraf:1.26.3-alpine
depends_on:
influxdb:
condition: service_healthy
mqtt:
condition: service_healthy
influxdb:
image: influxdb:2.7.1-alpine
healthcheck:
test: "curl -f http://localhost:8086/health || exit 1"
interval: 5s
timeout: 10s
retries: 5
```

__Desired behavior:__
Influxdb container can define its own healthcheck, thereby standardizing the health check, and saving users a manual step. Also, it's more likely that you folks as maintainers know the best and most correct health check, as compared to whatever else we come up with as users. Also you'll know the best parameters to the health check, like interval, timeout, etc.

For example, vernemq has this line in the Dockerfile:

```
HEALTHCHECK &{["CMD-SHELL" "vernemq ping | grep -q pong"] "0s" "0s" "0s" '\x00'}
```

__Alternatives considered:__
The alternative is to continue to put the work on users to create their own healthcheck instruction.

__Use case:__
This is really more of a completeness and "good behavior" request.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the Dockerfile used for the InfluxDB image and review the /health endpoint and HEALTHCHECK example described in the issue. Confirm that the chosen command and timing options work in the image; done means the image declares a suitable health check and the relevant container build or checks pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, dockerfile
Domain
devops
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.