Skip to content

[BUG] Docker healthcheck fails due to unresolved localhost #418

@paulgit

Description

@paulgit

Description

The Docker healthcheck in the Dockerfile fails because localhost does not resolve inside the Alpine Linux container, even though the application is functioning correctly. This causes Docker Compose to mark the container as unhealthy despite the /health endpoint being accessible and working.

To Reproduce

Steps to reproduce the behavior:

  1. Build and run the oxicloud Docker image using Docker Compose
  2. Monitor the container status with docker compose ps
  3. Observe that the container shows as (unhealthy) despite the application running normally
  4. Execute docker compose exec oxicloud wget -qO- http://localhost:8086/health and see "Connection refused"
  5. Execute docker compose exec oxicloud wget -qO- http://127.0.0.1:8086/health and see {"status":"ok"}

Expected Behavior

The container should report as healthy since the /health endpoint responds correctly with {"status":"ok"}.

Screenshots

N/A

Environment

  • OS: Ubuntu 24.04 (but affects all Alpine-based deployments)
  • OxiCloud Version: Latest (diocrafts/oxicloud:latest)
  • Docker Image Base: Alpine 3.23.3
  • Rust Version: 1.94.1

Additional Context

The issue is specific to hostname resolution within the Alpine container. While localhost is not resolvable, 127.0.0.1 resolves correctly and the healthcheck succeeds when using the IP address directly.

Possible Solution

Change the HEALTHCHECK command in the Dockerfile from:

CMD wget -qO- http://localhost:8086/health || exit 1

to

CMD wget -qO- http://127.0.0.1:8086/health || exit 1

This uses the numeric IP address instead of the hostname, which is reliably available in all container environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions