Go Prometheus guide: healthcheck uses wrong port and lacks curl

Aperta Adatta ai principianti
#26,129 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, go

Direzione di ricerca

Inizia da compose.yaml, dall'esempio Compose in README.md, da main.go e dal Dockerfile dello stage finale nell'esempio go-prometheus-monitoring. Confronta l'healthcheck con il listener :8000 dell'API e con gli strumenti installati nell'immagine Alpine finale. Il lavoro è completato quando gli healthcheck documentati e quelli dell'esempio usano la porta corretta, il relativo comando è disponibile e segnalano che il container è integro dopo una nuova build.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Markdown
Stelle
4.7k
Fork
8.5k
Merge medio
2g 18h
PR unite (30g)
108

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di docker/docs

Tutte le issue di docker/docs

Issue simili

Altre issue su DevOps

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.