Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/reference/commandline/container_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,28 @@ $ docker run --pull=never hello-world
docker: Error response from daemon: No such image: hello-world:latest.
```

### <a name="health-cmd"></a> Health checks (--health-cmd)

`--health-cmd` sets a command the daemon runs to decide if the container is
healthy. Unlike `HEALTHCHECK` in a Dockerfile, which can choose `CMD` or
`CMD-SHELL`, runtime `--health-cmd` is always executed with `CMD-SHELL`
(the image's shell, typically `/bin/sh -c`).

That means images without a shell — for example anything `FROM scratch` that
only has a static binary — cannot use `--health-cmd` unless you also provide a
shell in the image. For those images, define a `HEALTHCHECK` with the `CMD`
form in the Dockerfile instead (not `CMD-SHELL`), or bake a shell into a
minimal base image.

```console
$ docker run --name=test -d \
--health-cmd='stat /etc/passwd || exit 1' \
--health-interval=2s \
busybox sleep 1d
$ docker inspect --format='{{.State.Health.Status}}' test
healthy
```

### <a name="env"></a> Set environment variables (-e, --env, --env-file)

```console
Expand Down