docs: update documentation with new sections and improve clarity

This commit is contained in:
Jan Rundshagen 2025-03-29 13:11:47 +01:00 committed by Jan O. Rundshagen
parent ca0d37a4ac
commit d2a21afcfe
20 changed files with 128 additions and 73 deletions

View file

@ -1,10 +1,10 @@
## Executing commands before and after updating
# Executing commands before and after updating
!!! note
!!! note
These are shell commands executed with `sh`, and therefore require the container to provide the `sh`
executable.
> **DO NOTE**: If the container is not running then lifecycle hooks can not run and therefore
> **DO NOTE**: If the container is not running then lifecycle hooks can not run and therefore
> the update is executed without running any lifecycle hooks.
It is possible to execute _pre/post\-check_ and _pre/post\-update_ commands
@ -19,14 +19,14 @@ This feature is disabled by default. To enable it, you need to set the option
`--enable-lifecycle-hooks` on the command line, or set the environment variable
`WATCHTOWER_LIFECYCLE_HOOKS` to `true`.
### Specifying update commands
## Specifying update commands
The commands are specified using docker container labels, the following are currently available:
| Type | Docker Container Label |
| ----------- | ------------------------------------------------------ |
| ----------- | ------------------------------------------------------ |
| Pre Check | `com.centurylinklabs.watchtower.lifecycle.pre-check` |
| Pre Update | `com.centurylinklabs.watchtower.lifecycle.pre-update` |
| Pre Update | `com.centurylinklabs.watchtower.lifecycle.pre-update` |
| Post Update | `com.centurylinklabs.watchtower.lifecycle.post-update` |
| Post Check | `com.centurylinklabs.watchtower.lifecycle.post-check` |
@ -34,7 +34,7 @@ These labels can be declared as instructions in a Dockerfile (with some example
the `docker run` command line:
=== "Dockerfile"
```docker
```docker
LABEL com.centurylinklabs.watchtower.lifecycle.pre-check="/sync.sh"
LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="/dump-data.sh"
LABEL com.centurylinklabs.watchtower.lifecycle.post-update="/restore-data.sh"
@ -42,7 +42,7 @@ the `docker run` command line:
```
=== "docker run"
```bash
```bash
docker run -d \
--label=com.centurylinklabs.watchtower.lifecycle.pre-check="/sync.sh" \
--label=com.centurylinklabs.watchtower.lifecycle.pre-update="/dump-data.sh" \
@ -50,20 +50,21 @@ the `docker run` command line:
someimage --label=com.centurylinklabs.watchtower.lifecycle.post-check="/send-heartbeat.sh" \
```
### Timeouts
## Timeouts
The timeout for all lifecycle commands is 60 seconds. After that, a timeout will
occur, forcing Watchtower to continue the update loop.
#### Pre- or Post-update timeouts
### Pre- or Post-update timeouts
For the `pre-update` or `post-update` lifecycle command, it is possible to override this timeout to
allow the script to finish before forcefully killing it. This is done by adding the
label `com.centurylinklabs.watchtower.lifecycle.pre-update-timeout` or post-update-timeout respectively followed by
the timeout expressed in minutes.
If the label value is explicitly set to `0`, the timeout will be disabled.
If the label value is explicitly set to `0`, the timeout will be disabled.
### Execution failure
## Execution failure
The failure of a command to execute, identified by an exit code different than
0 or 75 (EX_TEMPFAIL), will not prevent watchtower from updating the container. Only an error