Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung | |||
| modul:m347:learningunits:lu03:lu03a:healthcheck [2025/05/13 18:55] – dgaravaldi | modul:m347:learningunits:lu03:lu03a:healthcheck [2025/05/15 15:48] (aktuell) – [HEALTHCHECK options] dgaravaldi | ||
|---|---|---|---|
| Zeile 56: | Zeile 56: | ||
| In addition to the CMD keyword, the HEALTHCHECK instruction also supports several options that allow you to configure the behavior of the health check: | In addition to the CMD keyword, the HEALTHCHECK instruction also supports several options that allow you to configure the behavior of the health check: | ||
| - | * The '' | + | * The '' |
| - | + | ||
| - | < | + | |
| - | HEALTHCHECK --interval=1m CMD < | + | |
| - | </ | + | |
| * The '' | * The '' | ||
| * The '' | * The '' | ||
| Zeile 67: | Zeile 62: | ||
| \\ | \\ | ||
| + | === Example === | ||
| + | < | ||
| + | FROM node:alpine | ||
| + | # Install curl for health checks | ||
| + | RUN apk add --no-cache curl | ||
| + | WORKDIR /app | ||
| + | COPY package*.json ./ | ||
| + | RUN npm install | ||
| + | # Then copy the rest | ||
| + | COPY . . | ||
| + | EXPOSE 3000 | ||
| + | # healthcheck settings | ||
| + | HEALTHCHECK --interval=30s --timeout=3s --retries=3 \ | ||
| + | CMD curl -f http:// | ||
| + | # start npm | ||
| + | CMD [" | ||
| + | </ | ||
| + | |||
| + | Let's break down what this health check does: | ||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| ==== Custom Scripts for Complex Health Checks ==== | ==== Custom Scripts for Complex Health Checks ==== | ||
| For more complex health checks, you can write custom scripts that perform a series of tests on your application. These scripts can be written in any scripting language that your container supports, such as bash or python. | For more complex health checks, you can write custom scripts that perform a series of tests on your application. These scripts can be written in any scripting language that your container supports, such as bash or python. | ||