The loki unit came up 'unhealthy' after the quadlet cutover. Cause: a unit's HealthCmd reaches podman as CMD-SHELL, i.e. /bin/sh -c, and the loki image is distroless — no shell exists in it. The busybox command itself works (probed by hand: /ready answers 'ready'); it was the shell wrapper that could not run. podman does not accept an exec-form command through --health-cmd either: it stores a JSON array as one literal argument. The command therefore moves into dankclaw/loki/Containerfile as a HEALTHCHECK ... CMD [...] exec form, which is what that image exists for — it already ships the static busybox solely so a healthcheck has something to run. podman reads the image's healthcheck when the unit declares none.
25 lines
1.2 KiB
Docker
25 lines
1.2 KiB
Docker
# Loki + a static busybox.
|
|
#
|
|
# grafana/loki is distroless: no shell, no wget, so nothing can run inside the
|
|
# container to check it. This image drops a static busybox into it for the
|
|
# healthcheck. All Loki behavior is unchanged.
|
|
#
|
|
# The healthcheck lives HERE, in exec form, and not in the Quadlet unit: a
|
|
# unit's HealthCmd reaches podman as CMD-SHELL, which needs /bin/sh — the one
|
|
# thing this image does not have. Specifying it here is also what lets the
|
|
# container report its own health instead of looking merely "Up" while wedged.
|
|
#
|
|
# Build on dankclaw:
|
|
# podman build -t franksdank/loki:latest -f dankclaw/loki/Containerfile .
|
|
|
|
FROM docker.io/library/alpine:latest AS tools
|
|
# busybox-static is statically linked: the target images have no dynamic
|
|
# loader (loki is distroless), so the alpine default /bin/busybox (musl
|
|
# dynamic) would fail with "no such file or directory".
|
|
RUN apk add --no-cache busybox-static
|
|
|
|
FROM docker.io/grafana/loki:latest
|
|
COPY --from=tools /bin/busybox.static /usr/local/bin/busybox
|
|
# Exec form (JSON array): no shell is involved.
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
|
CMD ["/usr/local/bin/busybox", "wget", "--spider", "-q", "http://localhost:3100/ready"] |