Skip to content

Go Prometheus guide: healthcheck uses wrong port and lacks curl #26129

Description

@take-shino

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions