Automatically update Docker services whenever their image is updated. Inspired on containrrr/watchtower
You must add the xyz.megpoid.swarm-updater=true label to your service so the updater can delay the update of itself as
the last one.
deploy:
labels:
- xyz.megpoid.swarm-updater=true
placement:
constraints:
- node.role == manager
The endpoint /apis/swarm/v1/update can be called with a list of images that should be updated on matching services on
the swarm.
{
"images": [
"mycompany/myapp"
]
}Every command-line option has their corresponding environment variable to configure the updater.
--host, -HDocker daemon socket to connect to. Defaults to "unix:///var/run/docker.sock" but can be pointed at a remote Docker host by specifying a TCP endpoint as "tcp://hostname:port". The host value can also be provided by setting theDOCKER_HOSTenvironment variable.--config, -cDocker client configuration path. In this directory goes aconfig.jsonfile with the credentials of the private registries. Defaults to~/.docker.The path value can also be provided by setting theDOCKER_CONFIGenvironment variable.--schedule, -sCron expression in 6 fields (rather than the traditional 5) which defines when and how often to check for new images. An example:--schedule "0 0 4 * * *". The schedule can also be provided by setting theSCHEDULEenvironment variable. Defaults to 1 hour. Usenoneto run the process one time and exit afterward.--label-enable, -lWatch services where thexyz.megpoid.swarm-updater.enablelabel is set to true. The flag can also be provided by setting theLABEL_ENABLEenvironment variable to1.--blacklist, -bService that is excluded from updates. Can be defined multiple times and can be a regular expression. Either--label-enableor--blacklistcan be defined, but not both. The comma separated list can also be provided by setting theBLACKLISTenvironment variable.--tlsverify, -tUse TLS when connecting to the Docker socket and verify the server's certificate. The flag can also be provided by setting theDOCKER_TLS_VERIFYenvironment variable to1.--debug, -dEnables debug logging. Can also be enabled by setting theDEBUG=1environment variable.--listen, -aAddress to listen for upcoming swarm update requests. Can also be enabled by setting theLISTENenvironment variable.--apikey, -kKey to protect the update endpoint. Can also be enabled by setting theAPIKEYenvironment variable.--max-threads, mMax number of services that should be updating at once (default: 2)--help, -hShow documentation about the supported flags.
DOCKER_API_VERSIONto set the version of the API to reach, leave empty to use the minimum required for the app.DOCKER_CERT_PATHis the directory to load the certificates from. Used when--hostis a TCP endpoint.
A file must be placed on ~/.docker/config.json with the registry credentials (can be overriden with --config
or DOCKER_CONFIG). The file can be created by using docker login <registry> and saving the credentials.
You must add the xyz.megpoid.swarm-updater.update-only=true label to your service so only the image will be updated (
useful for cron tasks where the container isn't running most of the time). Note: the service will be reconfigured
with replicas: 0 so this does nothing with global replication.