mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
Watchtower HTTP API based updates (#432)
* Added HTTP API trigger to update running images * Adds HTTP API authentication token parameter and handling * Exposes port 8080 in Dockerfile to allow inter-container update triggering via HTTP API * Fixes codacy issue * Adds API usage doc * Fix grammar * Moves api logic to a package of its own * Makes WT exit if token has not been set in HTTP API mode * Adds lock to prevent concurrent updates when in HTTP API mode Co-authored-by: Simon Aronsson <simme@arcticbit.se>
This commit is contained in:
parent
557f4abcb4
commit
0217e116c4
6 changed files with 143 additions and 0 deletions
|
@ -193,6 +193,26 @@ Run an update attempt against a container name list one time immediately and exi
|
|||
Environment Variable: WATCHTOWER_RUN_ONCE
|
||||
Type: Boolean
|
||||
Default: false
|
||||
```
|
||||
|
||||
## HTTP API Mode
|
||||
Runs Watchtower in HTTP API mode, only allowing image updates to be triggered by an HTTP request.
|
||||
|
||||
```
|
||||
Argument: --http-api
|
||||
Environment Variable: WATCHTOWER_HTTP_API
|
||||
Type: Boolean
|
||||
Default: false
|
||||
```
|
||||
|
||||
## HTTP API Token
|
||||
Sets an authentication token to HTTP API requests.
|
||||
|
||||
```
|
||||
Argument: --http-api-token
|
||||
Environment Variable: WATCHTOWER_HTTP_API_TOKEN
|
||||
Type: String
|
||||
Default: -
|
||||
```
|
||||
|
||||
## Scheduling
|
||||
|
|
35
docs/http-api-mode.md
Normal file
35
docs/http-api-mode.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
Watchtower provides an HTTP API mode that enables an HTTP endpoint that can be requested to trigger container updating. The current available endpoint list is:
|
||||
|
||||
- `/v1/update` - triggers an update for all of the containers monitored by this Watchtower instance.
|
||||
|
||||
---
|
||||
|
||||
To enable this mode, use the flag `--http-api`. For example, in a Docker Compose config file:
|
||||
|
||||
```json
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
app-monitored-by-watchtower:
|
||||
image: myapps/monitored-by-watchtower
|
||||
labels:
|
||||
- "com.centurylinklabs.watchtower.enable=true"
|
||||
|
||||
watchtower:
|
||||
image: containrrr/watchtower
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
command: --debug --http-api
|
||||
environment:
|
||||
- WATCHTOWER_HTTP_API_TOKEN=mytoken
|
||||
labels:
|
||||
- "com.centurylinklabs.watchtower.enable=false"
|
||||
ports:
|
||||
- 8080:8080
|
||||
```
|
||||
|
||||
Notice that there is an environment variable named WATCHTOWER_HTTP_API_TOKEN. To prevent external services from accidentally triggering image updates, all of the requests have to contain a "Token" field, valued as the token defined in WATCHTOWER_HTTP_API_TOKEN, in their headers. In this case, there is a port bind to the host machine, allowing to request localhost:8080 to reach Watchtower. The following `curl` command would trigger an image update:
|
||||
|
||||
```bash
|
||||
curl -H "Token: mytoken" localhost:8080/v1/update
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue