feat: add a Docker HEALTHCHECK and document container probes

Open
#150 0 comments 0 reactions 0 assignees View on GitHub

@sun-9545sunoj is already working on this.

Since Nov 28, 2026.

  • #151 by @sun-9545sunoj — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, python

Research direction

Start in the runtime stage of the Dockerfile, where EXPOSE 8000 and the ENTRYPOINT (which passes --port 8000) live, and read src/tserve/server/serve.py around line 46 to see why /health only answers after bootstrap. Add the HEALTHCHECK from the issue, then document it in docs/server/docker.md. Settle the open port and start-period points first, since they decide the final check. Done means the container reports healthy on /health and the docs cover docker ps, inspect, Compose and Kubernetes probes.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.

The Docker images have no HEALTHCHECK. The runtime stage of the Dockerfile only has EXPOSE 8000 and the ENTRYPOINT, so docker ps and Compose never report the container as healthy. A Compose service that uses depends_on: condition: service_healthy can't wait for TServe.

This matters more than usual because of how TServe starts. Server.__init__ runs bootstrap(), which downloads, loads and warms up every model before uvicorn.run binds the port (src/tserve/server/serve.py:46). On a first start that can take minutes, and the port stays closed the whole time. From outside, a container that is still downloading weights looks the same as one that has hung.

Because of that ordering, once GET /health answers, every requested model is already loaded and warm. That makes /health a correct readiness signal today. Nothing uses it that way yet.

Describe the solution you'd like

  1. Add a HEALTHCHECK to the runtime stage of the Dockerfile. The slim image has no curl, so use the venv's Python:

    HEALTHCHECK --interval=30s --timeout=5s --start-period=10m --retries=3 \
        CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=4)"
    

    The long --start-period covers first-start weight downloads. Failures during the start period don't count against --retries, and the container is marked healthy as soon as the first check passes, so a warm start isn't delayed.

  2. Document it in docs/server/docker.md:

    • how to read the status (docker ps, docker inspect)
    • a Compose depends_on: condition: service_healthy example
    • matching Kubernetes probes: a startupProbe with a large failureThreshold for the download, plus readinessProbe and livenessProbe on /health

Open points

  • Port. The ENTRYPOINT passes --port 8000, but a user can override it by appending --port 9000, and the check would then fail. One option is to read the port from an env var (for example TSERVE_PORT, defaulting to 8000) in both the entrypoint and the check. Another is to document that the check assumes 8000.
  • Default --start-period. A cached-weights start takes seconds and a full cold start can take far longer. 10m is a guess, and users can override it with docker run --health-start-period.

Describe alternatives you've considered

Bind the port first and load models in the background, with a /ready endpoint that returns 503 until loading and warmup finish. That would give a true startup signal, but it changes the documented "models load before the port is bound" behaviour. It's a bigger change for a separate discussion. The HEALTHCHECK is useful either way.

Additional context

No change to the HTTP API or the Python package. Only the Dockerfile and the docs change.

Dominant language
Python
Stars
22
Forks
7
Avg merge
10d 10h
Merged PRs (30d)
5

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • Has a pull request template
  • No 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.

More from sktime/tserve

All issues in sktime/tserve

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.