Problem
Docker reports the humux container as unhealthy even though the app is running fine.
a35866b3061f ghcr.io/mattmezza/humux:latest "uv run python -m co…"
3 hours ago Up 3 hours (unhealthy) 0.0.0.0:6100->6100/tcp, [::]:6100->6100/tcp, 8000/tcp
Root cause
The HEALTHCHECK in the Dockerfile (Dockerfile:161-162) hardcodes port 8000:
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
But the app's port is configurable at runtime via the PORT environment variable (main.py:507):
port=int(environ.get("PORT", "8000")),
When the container is started with -e PORT=6100 (or any non-default port), the app listens on that port, but the health check continues probing port 8000. curl -f http://localhost:8000/health gets a connection refused, Docker counts 3 failed retries, and marks the container unhealthy.
Proposed fix
Make the HEALTHCHECK read the PORT env var with a fallback to 8000:
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f "http://localhost:${PORT:-8000}/health" || exit 1
This way:
- Default run (no
PORT set) → probes http://localhost:8000/health (unchanged behaviour)
- Custom port (
-e PORT=6100) → probes http://localhost:6100/health
- Zero code changes — purely a HEALTHCHECK CMD fix
Acceptance criteria
Problem
Docker reports the humux container as
unhealthyeven though the app is running fine.Root cause
The HEALTHCHECK in the Dockerfile (
Dockerfile:161-162) hardcodes port 8000:But the app's port is configurable at runtime via the
PORTenvironment variable (main.py:507):When the container is started with
-e PORT=6100(or any non-default port), the app listens on that port, but the health check continues probing port 8000.curl -f http://localhost:8000/healthgets a connection refused, Docker counts 3 failed retries, and marks the containerunhealthy.Proposed fix
Make the HEALTHCHECK read the
PORTenv var with a fallback to 8000:This way:
PORTset) → probeshttp://localhost:8000/health(unchanged behaviour)-e PORT=6100) → probeshttp://localhost:6100/healthAcceptance criteria
$PORTenv var with:-8000fallbackhealthy-e PORT=6100) reportshealthystart-periodandretriessettings are unchanged