mirror of
https://github.com/containrrr/watchtower.git
synced 2026-01-25 10:16:10 +01:00
feat: use configuration to enable update commands
This commit is contained in:
parent
0870d7b1c1
commit
a362cb34a8
3 changed files with 33 additions and 16 deletions
12
README.md
12
README.md
|
|
@ -99,6 +99,7 @@ docker run --rm v2tec/watchtower --help
|
|||
* `--label-enable` Watch containers where the `com.centurylinklabs.watchtower.enable` label is set to true.
|
||||
* `--cleanup` Remove old images after updating. When this flag is specified, watchtower will remove the old image after restarting a container with a new image. Use this option to prevent the accumulation of orphaned images on your system as containers are updated.
|
||||
* `--tlsverify` Use TLS when connecting to the Docker socket and verify the server's certificate.
|
||||
* `--enable-update-commands` Enable the execution of *pre-update* and *post-update* commands on containers updated by watchtower.
|
||||
* `--debug` Enable debug mode. When this option is specified you'll see more verbose logging in the watchtower log file.
|
||||
* `--help` Show documentation about the supported flags.
|
||||
|
||||
|
|
@ -275,16 +276,23 @@ docker run -d \
|
|||
-e WATCHTOWER_NOTIFICATION_MSTEAMS_USE_LOG_DATA=true \
|
||||
v2tec/watchtower
|
||||
```
|
||||
|
||||
## Executing commands before and after updating
|
||||
|
||||
It is possible to execute a *pre-update* command and a *post-update* command
|
||||
inside every container updated by watchtower. The *pre-update* command is
|
||||
executed before stopping the container, and the *post-update* command is
|
||||
executed after restarting the container.
|
||||
executed after restarting the container.
|
||||
|
||||
This feature is disabled by default. To enable it, you need to set the option
|
||||
`--enable-update-commands` on the command line, or set the environment variable
|
||||
`WATCHTOWER_ENABLE_UPDATE_COMMANDS` to true.
|
||||
|
||||
Both commands are shell commands executed with `sh`, and therefore require the
|
||||
container to provide the `sh` executable.
|
||||
|
||||
### Specifying update commands
|
||||
|
||||
The commands are specified using docker container labels, with
|
||||
*com.centurylinklabs.watchtower.pre-update-command* for the *pre-update*
|
||||
command and *com.centurylinklabs.watchtower.post-update-command* for the
|
||||
|
|
@ -306,6 +314,8 @@ docker run -d \
|
|||
someimage
|
||||
```
|
||||
|
||||
### Execution failure
|
||||
|
||||
The failure of a command to execute, identified by an exit code different than
|
||||
0, should not prevent watchtower from updating the container. Only an error
|
||||
log statement containing the exit code will be reported.
|
||||
Loading…
Add table
Add a link
Reference in a new issue