docker / docker/docs

Go Prometheus guide: healthcheck uses wrong port and lacks curl

Open Beginner friendly
#26,129 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status/triage
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:

  1. compose.yaml and the Compose example in README.md check http://localhost:8080/health, while main.go listens on :8000 and the Dockerfile exposes port 8000.
  2. The healthcheck invokes curl, but the final alpine:3.17 image 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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.