Go Prometheus guide: healthcheck uses wrong port and lacks curl
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 4.7k
- Forks
- 8.5k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 108
Description
Is this a docs issue?
- My issue is about the documentation content or website
Type of issue
Information is incorrect
Description
The Go + Prometheus + Grafana guide's sample starts the API successfully, but the container remains unhealthy.
I reproduced this using Docker Desktop on Windows 11.
The API itself was running, and Prometheus could access /metrics. The API logs showed successful HTTP 200 responses. However, docker compose ps reported the API container as unhealthy.
Inspecting the health status showed:
exec: "curl": executable file not found in $PATH
There are two related inconsistencies in the current sample:
compose.yamland the Compose example inREADME.mdcheckhttp://localhost:8080/health, whilemain.golistens on:8000and the Dockerfile exposes port8000.- The healthcheck invokes
curl, but the finalalpine:3.17image does not install it.
Relevant current configuration:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
router.Run(":8000")
FROM alpine:3.17 AS final
EXPOSE 8000
After changing the healthcheck port to 8000, installing curl, and rebuilding the API image, the container changed from unhealthy to healthy.
Sample repository: https://github.com/dockersamples/go-prometheus-monitoring
Location
https://docs.docker.com/guides/go-prometheus-monitoring/
Suggestion
Update the healthcheck in both compose.yaml and the README example to use port 8000:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
Also make the healthcheck executable available in the final image, for example:
RUN apk add --no-cache curl
Alternatively, use a healthcheck command that is already available in the final image.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with compose.yaml, the Compose example in README.md, main.go, and the final-stage Dockerfile in the go-prometheus-monitoring sample. Compare the healthcheck with the API's :8000 listener and the tools installed in the final Alpine image. Done means the documented and sample healthchecks use the correct port, have their command available, and report the container healthy after rebuilding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- devops, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100