18.2. Performing a health check using the command line
You can set a health check when creating the container on the command line.
Prerequisites
-
The
container-toolsmeta-package is installed.
Procedure
Define a health check:
$ podman run -dt --name=hc-container -p 8080:8080 --health-cmd='curl http://localhost:8080 || exit 1' --health-interval=0 registry.access.redhat.com/ubi10/httpd-24-
The
--health-cmdoption sets a health check command for the container. -
The
--health-interval=0option with 0 value indicates that you want to run the health check manually.
-
The
Check the health status of the
hc-containercontainer:Using the
podman inspectcommand:$ podman inspect --format='{{json .State.Health.Status}}' hc-container healthyUsing the
podman pscommand:$ podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a680c6919fe localhost/hc-container:latest /usr/bin/run-http... 2 minutes ago Up 2 minutes (healthy) hc-containerUsing the
podman healthcheck runcommand:$ podman healthcheck run hc-container healthy