{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Home","text":"Watchtower

A container-based solution for automating Docker container base image updates.

"},{"location":"#quick_start","title":"Quick Start","text":"

With watchtower you can update the running version of your containerized app simply by pushing a new image to the Docker Hub or your own image registry. Watchtower will pull down your new image, gracefully shut down your existing container and restart it with the same options that were used when it was deployed initially. Run the watchtower container with the following command:

docker rundocker-compose.yml
$ docker run -d \\\n--name watchtower \\\n-v /var/run/docker.sock:/var/run/docker.sock \\\ncontainrrr/watchtower\n
version: \"3\"\nservices:\n  watchtower:\n    image: containrrr/watchtower\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n
"},{"location":"arguments/","title":"Arguments","text":"

By default, watchtower will monitor all containers running within the Docker daemon to which it is pointed (in most cases this will be the local Docker daemon, but you can override it with the --host option described in the next section). However, you can restrict watchtower to monitoring a subset of the running containers by specifying the container names as arguments when launching watchtower.

$ docker run -d \\\n    --name watchtower \\\n    -v /var/run/docker.sock:/var/run/docker.sock \\\n    containrrr/watchtower \\\n    nginx redis\n

In the example above, watchtower will only monitor the containers named \"nginx\" and \"redis\" for updates -- all of the other running containers will be ignored. If you do not want watchtower to run as a daemon you can pass the --run-once flag and remove the watchtower container after its execution.

$ docker run --rm \\\n    -v /var/run/docker.sock:/var/run/docker.sock \\\n    containrrr/watchtower \\\n    --run-once \\\n    nginx redis\n

In the example above, watchtower will execute an upgrade attempt on the containers named \"nginx\" and \"redis\". Using this mode will enable debugging output showing all actions performed, as usage is intended for interactive users. Once the attempt is completed, the container will exit and remove itself due to the --rm flag.

When no arguments are specified, watchtower will monitor all running containers.

"},{"location":"arguments/#secretsfiles","title":"Secrets/Files","text":"

Some arguments can also reference a file, in which case the contents of the file are used as the value. This can be used to avoid putting secrets in the configuration file or command line.

The following arguments are currently supported (including their corresponding WATCHTOWER_ environment variables): - notification-url - notification-email-server-password - notification-slack-hook-url - notification-msteams-hook - notification-gotify-token - http-api-token

"},{"location":"arguments/#example_docker-compose_usage","title":"Example docker-compose usage","text":"
secrets:\n  access_token:\n    file: access_token\n\nservices:\n  watchtower:\n    secrets:\n      - access_token\n    environment:\n      - WATCHTOWER_HTTP_API_TOKEN=/run/secrets/access_token\n
"},{"location":"arguments/#help","title":"Help","text":"

Shows documentation about the supported flags.

            Argument: --help\nEnvironment Variable: N/A\n                Type: N/A\n             Default: N/A\n
"},{"location":"arguments/#time_zone","title":"Time Zone","text":"

Sets the time zone to be used by WatchTower's logs and the optional Cron scheduling argument (--schedule). If this environment variable is not set, Watchtower will use the default time zone: UTC. To find out the right value, see this list, find your location and use the value in TZ Database Name, e.g Europe/Rome. The timezone can alternatively be set by volume mounting your hosts /etc/localtime file. -v /etc/localtime:/etc/localtime:ro

            Argument: N/A\nEnvironment Variable: TZ\n                Type: String\n             Default: \"UTC\"\n
"},{"location":"arguments/#cleanup","title":"Cleanup","text":"

Removes 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.

            Argument: --cleanup\nEnvironment Variable: WATCHTOWER_CLEANUP\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#remove_anonymous_volumes","title":"Remove anonymous volumes","text":"

Removes anonymous volumes after updating. When this flag is specified, watchtower will remove all anonymous volumes from the container before restarting with a new image. Named volumes will not be removed!

            Argument: --remove-volumes\nEnvironment Variable: WATCHTOWER_REMOVE_VOLUMES\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#debug","title":"Debug","text":"

Enable debug mode with verbose logging.

Notes

Alias for --log-level debug. See Maximum log level. Does not take an argument when used as an argument. Using --debug true will not work.

            Argument: --debug, -d\nEnvironment Variable: WATCHTOWER_DEBUG\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#trace","title":"Trace","text":"

Enable trace mode with very verbose logging. Caution: exposes credentials!

Notes

Alias for --log-level trace. See Maximum log level. Does not take an argument when used as an argument. Using --trace true will not work.

            Argument: --trace\nEnvironment Variable: WATCHTOWER_TRACE\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#maximum_log_level","title":"Maximum log level","text":"

The maximum log level that will be written to STDERR (shown in docker log when used in a container).

            Argument: --log-level\nEnvironment Variable: WATCHTOWER_LOG_LEVEL\n     Possible values: panic, fatal, error, warn, info, debug or trace\n             Default: info\n
"},{"location":"arguments/#logging_format","title":"Logging format","text":"

Sets what logging format to use for console output.

            Argument: --log-format, -l\nEnvironment Variable: WATCHTOWER_LOG_FORMAT\n     Possible values: Auto, LogFmt, Pretty or JSON\n             Default: Auto\n
"},{"location":"arguments/#ansi_colors","title":"ANSI colors","text":"

Disable ANSI color escape codes in log output.

            Argument: --no-color\nEnvironment Variable: NO_COLOR\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#docker_host","title":"Docker host","text":"

Docker daemon socket to connect to. Can be pointed at a remote Docker host by specifying a TCP endpoint as \"tcp://hostname:port\".

            Argument: --host, -H\nEnvironment Variable: DOCKER_HOST\n                Type: String\n             Default: \"unix:///var/run/docker.sock\"\n
"},{"location":"arguments/#docker_api_version","title":"Docker API version","text":"

The API version to use by the Docker client for connecting to the Docker daemon. The minimum supported version is 1.24.

            Argument: --api-version, -a\nEnvironment Variable: DOCKER_API_VERSION\n                Type: String\n             Default: \"1.24\"\n
"},{"location":"arguments/#include_restarting","title":"Include restarting","text":"

Will also include restarting containers.

            Argument: --include-restarting\nEnvironment Variable: WATCHTOWER_INCLUDE_RESTARTING\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#include_stopped","title":"Include stopped","text":"

Will also include created and exited containers.

            Argument: --include-stopped, -S\nEnvironment Variable: WATCHTOWER_INCLUDE_STOPPED\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#revive_stopped","title":"Revive stopped","text":"

Start any stopped containers that have had their image updated. This argument is only usable with the --include-stopped argument.

            Argument: --revive-stopped\nEnvironment Variable: WATCHTOWER_REVIVE_STOPPED\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#poll_interval","title":"Poll interval","text":"

Poll interval (in seconds). This value controls how frequently watchtower will poll for new images. Either --schedule or a poll interval can be defined, but not both.

            Argument: --interval, -i\nEnvironment Variable: WATCHTOWER_POLL_INTERVAL\n                Type: Integer\n             Default: 86400 (24 hours)\n
"},{"location":"arguments/#filter_by_enable_label","title":"Filter by enable label","text":"

Monitor and update containers that have a com.centurylinklabs.watchtower.enable label set to true.

            Argument: --label-enable\nEnvironment Variable: WATCHTOWER_LABEL_ENABLE\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#filter_by_disable_label","title":"Filter by disable label","text":"

Do not Monitor and update containers that have com.centurylinklabs.watchtower.enable label set to false and no --label-enable argument is passed. Note that only one or the other (targeting by enable label) can be used at the same time to target containers.

"},{"location":"arguments/#filter_by_disabling_specific_container_names","title":"Filter by disabling specific container names","text":"

Monitor and update containers whose names are not in a given set of names.

This can be used to exclude specific containers, when setting labels is not an option. The listed containers will be excluded even if they have the enable filter set to true.

            Argument: --disable-containers, -x\nEnvironment Variable: WATCHTOWER_DISABLE_CONTAINERS\n                Type: Comma- or space-separated string list\n             Default: \"\"\n
"},{"location":"arguments/#without_updating_containers","title":"Without updating containers","text":"

Will only monitor for new images, send notifications and invoke the pre-check/post-check hooks, but will not update the containers.

Note

Due to Docker API limitations the latest image will still be pulled from the registry. The HEAD digest checks allows watchtower to skip pulling when there are no changes, but to know what has changed it will still do a pull whenever the repository digest doesn't match the local image digest.

            Argument: --monitor-only\nEnvironment Variable: WATCHTOWER_MONITOR_ONLY\n                Type: Boolean\n             Default: false\n

Note that monitor-only can also be specified on a per-container basis with the com.centurylinklabs.watchtower.monitor-only label set on those containers.

See With label taking precedence over arguments for behavior when both argument and label are set

"},{"location":"arguments/#with_label_taking_precedence_over_arguments","title":"With label taking precedence over arguments","text":"

By default, arguments will take precedence over labels. This means that if you set WATCHTOWER_MONITOR_ONLY to true or use --monitor-only, a container with com.centurylinklabs.watchtower.monitor-only set to false will not be updated. If you set WATCHTOWER_LABEL_TAKE_PRECEDENCE to true or use --label-take-precedence, then the container will also be updated. This also apply to the no pull option. if you set WATCHTOWER_NO_PULL to true or use --no-pull, a container with com.centurylinklabs.watchtower.no-pull set to false will not pull the new image. If you set WATCHTOWER_LABEL_TAKE_PRECEDENCE to true or use --label-take-precedence, then the container will pull image

            Argument: --label-take-precedence\nEnvironment Variable: WATCHTOWER_LABEL_TAKE_PRECEDENCE\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#without_restarting_containers","title":"Without restarting containers","text":"

Do not restart containers after updating. This option can be useful when the start of the containers is managed by an external system such as systemd.

            Argument: --no-restart\nEnvironment Variable: WATCHTOWER_NO_RESTART\n                Type: Boolean\n             Default: false\n

"},{"location":"arguments/#without_pulling_new_images","title":"Without pulling new images","text":"

Do not pull new images. When this flag is specified, watchtower will not attempt to pull new images from the registry. Instead it will only monitor the local image cache for changes. Use this option if you are building new images directly on the Docker host without pushing them to a registry.

            Argument: --no-pull\nEnvironment Variable: WATCHTOWER_NO_PULL\n                Type: Boolean\n             Default: false\n

Note that no-pull can also be specified on a per-container basis with the com.centurylinklabs.watchtower.no-pull label set on those containers.

See With label taking precedence over arguments for behavior when both argument and label are set

"},{"location":"arguments/#without_sending_a_startup_message","title":"Without sending a startup message","text":"

Do not send a message after watchtower started. Otherwise there will be an info-level notification.

            Argument: --no-startup-message\nEnvironment Variable: WATCHTOWER_NO_STARTUP_MESSAGE\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#run_once","title":"Run once","text":"

Run an update attempt against a container name list one time immediately and exit.

            Argument: --run-once, -R\nEnvironment Variable: WATCHTOWER_RUN_ONCE\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#http_api_mode","title":"HTTP API Mode","text":"

Runs Watchtower in HTTP API mode, only allowing image updates to be triggered by an HTTP request. For details see HTTP API.

            Argument: --http-api-update\nEnvironment Variable: WATCHTOWER_HTTP_API_UPDATE\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#http_api_token","title":"HTTP API Token","text":"

Sets an authentication token to HTTP API requests. Can also reference a file, in which case the contents of the file are used.

            Argument: --http-api-token\nEnvironment Variable: WATCHTOWER_HTTP_API_TOKEN\n                Type: String\n             Default: -\n
"},{"location":"arguments/#http_api_periodic_polls","title":"HTTP API periodic polls","text":"

Keep running periodic updates if the HTTP API mode is enabled, otherwise the HTTP API would prevent periodic polls.

            Argument: --http-api-periodic-polls\nEnvironment Variable: WATCHTOWER_HTTP_API_PERIODIC_POLLS\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#filter_by_scope","title":"Filter by scope","text":"

Update containers that have a com.centurylinklabs.watchtower.scope label set with the same value as the given argument. This enables running multiple instances.

Filter by lack of scope

If you want other instances of watchtower to ignore the scoped containers, set this argument to none. When omitted, watchtower will update all containers regardless of scope.

            Argument: --scope\nEnvironment Variable: WATCHTOWER_SCOPE\n                Type: String\n             Default: -\n
"},{"location":"arguments/#http_api_metrics","title":"HTTP API Metrics","text":"

Enables a metrics endpoint, exposing prometheus metrics via HTTP. See Metrics for details.

            Argument: --http-api-metrics\nEnvironment Variable: WATCHTOWER_HTTP_API_METRICS\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#scheduling","title":"Scheduling","text":"

Cron expression in 6 fields (rather than the traditional 5) which defines when and how often to check for new images. Either --interval or the schedule expression can be defined, but not both. An example: --schedule \"0 0 4 * * *\"

            Argument: --schedule, -s\nEnvironment Variable: WATCHTOWER_SCHEDULE\n                Type: String\n             Default: -\n
"},{"location":"arguments/#rolling_restart","title":"Rolling restart","text":"

Restart one image at time instead of stopping and starting all at once. Useful in conjunction with lifecycle hooks to implement zero-downtime deploy.

            Argument: --rolling-restart\nEnvironment Variable: WATCHTOWER_ROLLING_RESTART\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#wait_until_timeout","title":"Wait until timeout","text":"

Timeout before the container is forcefully stopped. When set, this option will change the default (10s) wait time to the given value. An example: --stop-timeout 30s will set the timeout to 30 seconds.

            Argument: --stop-timeout\nEnvironment Variable: WATCHTOWER_TIMEOUT\n                Type: Duration\n             Default: 10s\n
"},{"location":"arguments/#tls_verification","title":"TLS Verification","text":"

Use TLS when connecting to the Docker socket and verify the server's certificate. See below for options used to configure notifications.

            Argument: --tlsverify\nEnvironment Variable: DOCKER_TLS_VERIFY\n                Type: Boolean\n             Default: false\n
"},{"location":"arguments/#head_failure_warnings","title":"HEAD failure warnings","text":"

When to warn about HEAD pull requests failing. Auto means that it will warn when the registry is known to handle the requests and may rate limit pull requests (mainly docker.io).

            Argument: --warn-on-head-failure\nEnvironment Variable: WATCHTOWER_WARN_ON_HEAD_FAILURE\n     Possible values: always, auto, never\n             Default: auto\n
"},{"location":"arguments/#health_check","title":"Health check","text":"

Returns a success exit code to enable usage with docker HEALTHCHECK. This check is naive and only returns checks whether there is another process running inside the container, as it is the only known form of failure state for watchtowers container.

Only for HEALTHCHECK use

Never put this on the main container executable command line as it is only meant to be run from docker HEALTHCHECK.

            Argument: --health-check\n
"},{"location":"arguments/#programatic_output_porcelain","title":"Programatic Output (porcelain)","text":"

Writes the session results to STDOUT using a stable, machine-readable format (indicated by the argument VERSION).

Alias for:

        --notification-url logger://\n        --notification-log-stdout\n        --notification-report\n        --notification-template porcelain.VERSION.summary-no-log\n\n            Argument: --porcelain, -P\nEnvironment Variable: WATCHTOWER_PORCELAIN\n     Possible values: v1\n             Default: -\n
"},{"location":"container-selection/","title":"Container selection","text":"

By default, watchtower will watch all containers. However, sometimes only some containers should be updated.

There are two options:

"},{"location":"container-selection/#full_exclude","title":"Full Exclude","text":"

If you need to exclude some containers, set the com.centurylinklabs.watchtower.enable label to false. For clarity this should be set on the container(s) you wish to be ignored, this is not set on watchtower.

dockerfiledocker rundocker-compose
LABEL com.centurylinklabs.watchtower.enable=\"false\"\n
docker run -d --label=com.centurylinklabs.watchtower.enable=false someimage\n
version: \"3\"\nservices:\n  someimage:\n    container_name: someimage\n    labels:\n      - \"com.centurylinklabs.watchtower.enable=false\"\n

If instead you want to only include containers with the enable label, pass the --label-enable flag or the WATCHTOWER_LABEL_ENABLE environment variable on startup for watchtower and set the com.centurylinklabs.watchtower.enable label with a value of true on the containers you want to watch.

dockerfiledocker rundocker-compose
LABEL com.centurylinklabs.watchtower.enable=\"true\"\n
docker run -d --label=com.centurylinklabs.watchtower.enable=true someimage\n
version: \"3\"\nservices:\n  someimage:\n    container_name: someimage\n    labels:\n      - \"com.centurylinklabs.watchtower.enable=true\"\n

If you wish to create a monitoring scope, you will need to run multiple instances and set a scope for each of them.

Watchtower filters running containers by testing them against each configured criteria. A container is monitored if all criteria are met. For example:

"},{"location":"container-selection/#monitor_only","title":"Monitor Only","text":"

Individual containers can be marked to only be monitored (without being updated).

To do so, set the com.centurylinklabs.watchtower.monitor-only label to true on that container.

LABEL com.centurylinklabs.watchtower.monitor-only=\"true\"\n

Or, it can be specified as part of the docker run command line:

docker run -d --label=com.centurylinklabs.watchtower.monitor-only=true someimage\n

When the label is specified on a container, watchtower treats that container exactly as if WATCHTOWER_MONITOR_ONLY was set, but the effect is limited to the individual container.

"},{"location":"http-api-mode/","title":"HTTP API Mode","text":"

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:

To enable this mode, use the flag --http-api-update. For example, in a Docker Compose config file:

version: '3'\n\nservices:\n  app-monitored-by-watchtower:\n    image: myapps/monitored-by-watchtower\n    labels:\n      - \"com.centurylinklabs.watchtower.enable=true\"\n\n  watchtower:\n    image: containrrr/watchtower\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n    command: --debug --http-api-update\n    environment:\n      - WATCHTOWER_HTTP_API_TOKEN=mytoken\n    labels:\n      - \"com.centurylinklabs.watchtower.enable=false\"\n    ports:\n      - 8080:8080\n

By default, enabling this mode prevents periodic polls (i.e. what is specified using --interval or --schedule). To run periodic updates regardless, pass --http-api-periodic-polls.

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:

curl -H \"Authorization: Bearer mytoken\" localhost:8080/v1/update\n
"},{"location":"introduction/","title":"Introduction","text":"

Watchtower is an application that will monitor your running Docker containers and watch for changes to the images that those containers were originally started from. If watchtower detects that an image has changed, it will automatically restart the container using the new image.

With watchtower you can update the running version of your containerized app simply by pushing a new image to the Docker Hub or your own image registry. Watchtower will pull down your new image, gracefully shut down your existing container and restart it with the same options that were used when it was deployed initially.

For example, let's say you were running watchtower along with an instance of centurylink/wetty-cli image:

$ docker ps\nCONTAINER ID   IMAGE                   STATUS          PORTS                    NAMES\n967848166a45   centurylink/wetty-cli   Up 10 minutes   0.0.0.0:8080->3000/tcp   wetty\n6cc4d2a9d1a5   containrrr/watchtower   Up 15 minutes                            watchtower\n

Every day watchtower will pull the latest centurylink/wetty-cli image and compare it to the one that was used to run the \"wetty\" container. If it sees that the image has changed it will stop/remove the \"wetty\" container and then restart it using the new image and the same docker run options that were used to start the container initially (in this case, that would include the -p 8080:3000 port mapping).

"},{"location":"lifecycle-hooks/","title":"Lifecycle hooks","text":""},{"location":"lifecycle-hooks/#executing_commands_before_and_after_updating","title":"Executing commands before and after updating","text":"

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 the update is executed without running any lifecycle hooks.

It is possible to execute pre/post-check and pre/post-update commands inside every container updated by watchtower.

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.

"},{"location":"lifecycle-hooks/#specifying_update_commands","title":"Specifying update commands","text":"

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 Post Update com.centurylinklabs.watchtower.lifecycle.post-update Post Check com.centurylinklabs.watchtower.lifecycle.post-check

These labels can be declared as instructions in a Dockerfile (with some example .sh files) or be specified as part of the docker run command line:

Dockerfiledocker run
LABEL com.centurylinklabs.watchtower.lifecycle.pre-check=\"/sync.sh\"\nLABEL com.centurylinklabs.watchtower.lifecycle.pre-update=\"/dump-data.sh\"\nLABEL com.centurylinklabs.watchtower.lifecycle.post-update=\"/restore-data.sh\"\nLABEL com.centurylinklabs.watchtower.lifecycle.post-check=\"/send-heartbeat.sh\"\n
docker run -d \\\n--label=com.centurylinklabs.watchtower.lifecycle.pre-check=\"/sync.sh\" \\\n--label=com.centurylinklabs.watchtower.lifecycle.pre-update=\"/dump-data.sh\" \\\n--label=com.centurylinklabs.watchtower.lifecycle.post-update=\"/restore-data.sh\" \\\nsomeimage --label=com.centurylinklabs.watchtower.lifecycle.post-check=\"/send-heartbeat.sh\" \\\n
"},{"location":"lifecycle-hooks/#timeouts","title":"Timeouts","text":"

The timeout for all lifecycle commands is 60 seconds. After that, a timeout will occur, forcing Watchtower to continue the update loop.

"},{"location":"lifecycle-hooks/#pre-_or_post-update_timeouts","title":"Pre- or Post-update timeouts","text":"

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.

"},{"location":"lifecycle-hooks/#execution_failure","title":"Execution failure","text":"

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 log statement containing the exit code will be reported.

"},{"location":"linked-containers/","title":"Linked containers","text":"

Watchtower will detect if there are links between any of the running containers and ensures that things are stopped/started in a way that won't break any of the links. If an update is detected for one of the dependencies in a group of linked containers, watchtower will stop and start all of the containers in the correct order so that the application comes back up correctly.

For example, imagine you were running a mysql container and a wordpress container which had been linked to the mysql container. If watchtower were to detect that the mysql container required an update, it would first shut down the linked wordpress container followed by the mysql container. When restarting the containers it would handle mysql first and then wordpress to ensure that the link continued to work.

If you want to override existing links, or if you are not using links, you can use special com.centurylinklabs.watchtower.depends-on label with dependent container names, separated by a comma.

When you have a depending container that is using network_mode: service:container then watchtower will treat that container as an implicit link.

"},{"location":"metrics/","title":"Metrics","text":"

Experimental feature

This feature was added in v1.0.4 and is still considered experimental. If you notice any strange behavior, please raise a ticket in the repository issues.

Metrics can be used to track how Watchtower behaves over time.

To use this feature, you have to set an API token and enable the metrics API, as well as creating a port mapping for your container for port 8080.

The metrics API endpoint is /v1/metrics.

"},{"location":"metrics/#available_metrics","title":"Available Metrics","text":"Name Type Description watchtower_containers_scanned Gauge Number of containers scanned for changes by watchtower during the last scan watchtower_containers_updated Gauge Number of containers updated by watchtower during the last scan watchtower_containers_failed Gauge Number of containers where update failed during the last scan watchtower_scans_total Counter Number of scans since the watchtower started watchtower_scans_skipped Counter Number of skipped scans since watchtower started"},{"location":"metrics/#example_prometheus_scrape_config","title":"Example Prometheus scrape_config","text":"
scrape_configs:\n  - job_name: watchtower\n    scrape_interval: 5s\n    metrics_path: /v1/metrics\n    bearer_token: demotoken\n    static_configs:\n      - targets:\n        - 'watchtower:8080'\n

Replace demotoken with the Bearer token you have set accordingly.

"},{"location":"metrics/#demo","title":"Demo","text":"

The repository contains a demo with prometheus and grafana, available through docker-compose.yml. This demo is preconfigured with a dashboard, which will look something like this:

"},{"location":"notifications/","title":"Notifications","text":"

Watchtower can send notifications when containers are updated. Notifications are sent via hooks in the logging system, logrus.

Using multiple notifications with environment variables

There is currently a bug in Viper (spf13/viper#380), which prevents comma-separated slices to be used when using the environment variable. A workaround is available where we instead put quotes around the environment variable value and replace the commas with spaces:

WATCHTOWER_NOTIFICATIONS=\"slack msteams\"\n
If you're a docker-compose user, make sure to specify environment variables' values in your .yml file without double quotes (\"). This prevents unexpected errors when watchtower starts.

"},{"location":"notifications/#settings","title":"Settings","text":""},{"location":"notifications/#shoutrrr_notifications","title":"shoutrrr notifications","text":"

To send notifications via shoutrrr, the following command-line options, or their corresponding environment variables, can be set:

Go to containrrr.dev/shoutrrr/v0.8/services/overview to learn more about the different service URLs you can use. You can define multiple services by space separating the URLs. (See example below)

You can customize the message posted by setting a template.

The template is a Go template that either format a list of log entries or a notification.Data struct.

Simple templates are used unless the notification-report flag is specified:

"},{"location":"notifications/#simple_templates","title":"Simple templates","text":"

The default value if not set is {{range .}}{{.Message}}{{println}}{{end}}. The example below uses a template that also outputs timestamp and log level.

Custom date format

If you want to adjust the date/time format it must show how the reference time (Mon Jan 2 15:04:05 MST 2006) would be displayed in your custom format. i.e., The day of the year has to be 1, the month has to be 2 (february), the hour 3 (or 15 for 24h time) etc.

Example:

docker run -d \\\n  --name watchtower \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -e WATCHTOWER_NOTIFICATION_URL=\"discord://token@channel slack://watchtower@token-a/token-b/token-c\" \\\n  -e WATCHTOWER_NOTIFICATION_TEMPLATE=\"{{range .}}{{.Time.Format \\\"2006-01-02 15:04:05\\\"}} ({{.Level}}): {{.Message}}{{println}}{{end}}\" \\\n  containrrr/watchtower\n
"},{"location":"notifications/#report_templates","title":"Report templates","text":"

The default template for report notifications are the following:

{{- if .Report -}}\n  {{- with .Report -}}\n    {{- if ( or .Updated .Failed ) -}}\n{{len .Scanned}} Scanned, {{len .Updated}} Updated, {{len .Failed}} Failed\n      {{- range .Updated}}\n- {{.Name}} ({{.ImageName}}): {{.CurrentImageID.ShortID}} updated to {{.LatestImageID.ShortID}}\n      {{- end -}}\n      {{- range .Fresh}}\n- {{.Name}} ({{.ImageName}}): {{.State}}\n      {{- end -}}\n      {{- range .Skipped}}\n- {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}\n      {{- end -}}\n      {{- range .Failed}}\n- {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}\n      {{- end -}}\n    {{- end -}}\n  {{- end -}}\n{{- else -}}\n  {{range .Entries -}}{{.Message}}{{\"\\n\"}}{{- end -}}\n{{- end -}}\n

It will be used to send a summary of every session if there are any containers that were updated or which failed to update.

Skipping notifications

Whenever the result of applying the template results in an empty string, no notifications will be sent. This is by default used to limit the notifications to only be sent when there something noteworthy occurred.

You can replace {{- if ( or .Updated .Failed ) -}} with any logic you want to decide when to send the notifications.

Example using a custom report template that always sends a session report after each run:

docker rundocker-compose
docker run -d \\\n  --name watchtower \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -e WATCHTOWER_NOTIFICATION_REPORT=\"true\" \\\n  -e WATCHTOWER_NOTIFICATION_URL=\"discord://token@channel slack://watchtower@token-a/token-b/token-c\" \\\n  -e WATCHTOWER_NOTIFICATION_TEMPLATE=\"\n  {{- if .Report -}}\n    {{- with .Report -}}\n  {{len .Scanned}} Scanned, {{len .Updated}} Updated, {{len .Failed}} Failed\n        {{- range .Updated}}\n  - {{.Name}} ({{.ImageName}}): {{.CurrentImageID.ShortID}} updated to {{.LatestImageID.ShortID}}\n        {{- end -}}\n        {{- range .Fresh}}\n  - {{.Name}} ({{.ImageName}}): {{.State}}\n      {{- end -}}\n      {{- range .Skipped}}\n  - {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}\n      {{- end -}}\n      {{- range .Failed}}\n  - {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}\n      {{- end -}}\n    {{- end -}}\n  {{- else -}}\n    {{range .Entries -}}{{.Message}}{{\\\"\\n\\\"}}{{- end -}}\n  {{- end -}}\n  \" \\\n  containrrr/watchtower\n
version: \"3\"\nservices:\n  watchtower:\n    image: containrrr/watchtower\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n    env:\n      WATCHTOWER_NOTIFICATION_REPORT: \"true\"\n      WATCHTOWER_NOTIFICATION_URL: >\n        discord://token@channel\n        slack://watchtower@token-a/token-b/token-c\n      WATCHTOWER_NOTIFICATION_TEMPLATE: |\n        {{- if .Report -}}\n          {{- with .Report -}}\n        {{len .Scanned}} Scanned, {{len .Updated}} Updated, {{len .Failed}} Failed\n              {{- range .Updated}}\n        - {{.Name}} ({{.ImageName}}): {{.CurrentImageID.ShortID}} updated to {{.LatestImageID.ShortID}}\n              {{- end -}}\n              {{- range .Fresh}}\n        - {{.Name}} ({{.ImageName}}): {{.State}}\n            {{- end -}}\n            {{- range .Skipped}}\n        - {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}\n            {{- end -}}\n            {{- range .Failed}}\n        - {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}}\n            {{- end -}}\n          {{- end -}}\n        {{- else -}}\n          {{range .Entries -}}{{.Message}}{{\"\\n\"}}{{- end -}}\n        {{- end -}}\n
"},{"location":"notifications/#legacy_notifications","title":"Legacy notifications","text":"

For backwards compatibility, the notifications can also be configured using legacy notification options. These will automatically be converted to shoutrrr URLs when used. The types of notifications to send are set by passing a comma-separated list of values to the --notifications option (or corresponding environment variable WATCHTOWER_NOTIFICATIONS), which has the following valid values:

"},{"location":"notifications/#notify-upgrade","title":"notify-upgrade","text":"

If watchtower is started with notify-upgrade as it's first argument, it will generate a .env file with your current legacy notification options converted to shoutrrr URLs.

docker rundocker-compose.yml
$ docker run -d \\\n--name watchtower \\\n-v /var/run/docker.sock:/var/run/docker.sock \\\n-e WATCHTOWER_NOTIFICATIONS=slack \\\n-e WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL=\"https://hooks.slack.com/services/xxx/yyyyyyyyyyyyyyy\" \\\ncontainrrr/watchtower \\\nnotify-upgrade\n
version: \"3\"\nservices:\n  watchtower:\n    image: containrrr/watchtower\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n    env:\n      WATCHTOWER_NOTIFICATIONS: slack\n      WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL: https://hooks.slack.com/services/xxx/yyyyyyyyyyyyyyy\n    command: notify-upgrade\n

You can then copy this file from the container (a message with the full command to do so will be logged) and use it with your current setup:

docker rundocker-compose.yml
$ docker run -d \\\n--name watchtower \\\n-v /var/run/docker.sock:/var/run/docker.sock \\\n--env-file watchtower-notifications.env \\\ncontainrrr/watchtower\n
version: \"3\"\nservices:\n  watchtower:\n    image: containrrr/watchtower\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n    env_file:\n      - watchtower-notifications.env\n
"},{"location":"notifications/#email","title":"Email","text":"

To receive notifications by email, the following command-line options, or their corresponding environment variables, can be set:

Example:

docker run -d \\\n  --name watchtower \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -e WATCHTOWER_NOTIFICATIONS=email \\\n  -e WATCHTOWER_NOTIFICATION_EMAIL_FROM=fromaddress@gmail.com \\\n  -e WATCHTOWER_NOTIFICATION_EMAIL_TO=toaddress@gmail.com \\\n  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.gmail.com \\\n  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587 \\\n  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=fromaddress@gmail.com \\\n  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=app_password \\\n  -e WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2 \\\n  containrrr/watchtower\n

The previous example assumes, that you already have an SMTP server up and running you can connect to. If you don't or you want to bring up watchtower with your own simple SMTP relay the following docker-compose.yml might be a good start for you.

The following example assumes, that your domain is called your-domain.com and that you are going to use a certificate valid for smtp.your-domain.com. This hostname has to be used as WATCHTOWER_NOTIFICATION_EMAIL_SERVER otherwise the TLS connection is going to fail with Failed to send notification email or connect: connection refused. We also have to add a network for this setup in order to add an alias to it. If you also want to enable DKIM or other features on the SMTP server, you will find more information at freinet/postfix-relay.

Example including an SMTP relay:

version: '3.8'\nservices:\n  watchtower:\n    image: containrrr/watchtower:latest\n    container_name: watchtower\n    environment:\n      WATCHTOWER_MONITOR_ONLY: 'true'\n      WATCHTOWER_NOTIFICATIONS: email\n      WATCHTOWER_NOTIFICATION_EMAIL_FROM: from-address@your-domain.com\n      WATCHTOWER_NOTIFICATION_EMAIL_TO: to-address@your-domain.com\n      # you have to use a network alias here, if you use your own certificate\n      WATCHTOWER_NOTIFICATION_EMAIL_SERVER: smtp.your-domain.com\n      WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT: 25\n      WATCHTOWER_NOTIFICATION_EMAIL_DELAY: 2\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n    networks:\n      - watchtower\n    depends_on:\n      - postfix\n\n  # SMTP needed to send out status emails\n  postfix:\n    image: freinet/postfix-relay:latest\n    expose:\n      - 25\n    environment:\n      MAILNAME: somename.your-domain.com\n      TLS_KEY: '/etc/ssl/domains/your-domain.com/your-domain.com.key'\n      TLS_CRT: '/etc/ssl/domains/your-domain.com/your-domain.com.crt'\n      TLS_CA: '/etc/ssl/domains/your-domain.com/intermediate.crt'\n    volumes:\n      - /etc/ssl/domains/your-domain.com/:/etc/ssl/domains/your-domain.com/:ro\n    networks:\n      watchtower:\n        # this alias is really important to make your certificate work\n        aliases:\n          - smtp.your-domain.com\nnetworks:\n  watchtower:\n    external: false\n
"},{"location":"notifications/#slack","title":"Slack","text":"

To receive notifications in Slack, add slack to the --notifications option or the WATCHTOWER_NOTIFICATIONS environment variable.

Additionally, you should set the Slack webhook URL using the --notification-slack-hook-url option or the WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL environment variable. This option can also reference a file, in which case the contents of the file are used.

By default, watchtower will send messages under the name watchtower, you can customize this string through the --notification-slack-identifier option or the WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER environment variable.

Other, optional, variables include:

Example:

docker run -d \\\n  --name watchtower \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -e WATCHTOWER_NOTIFICATIONS=slack \\\n  -e WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL=\"https://hooks.slack.com/services/xxx/yyyyyyyyyyyyyyy\" \\\n  -e WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER=watchtower-server-1 \\\n  -e WATCHTOWER_NOTIFICATION_SLACK_CHANNEL=#my-custom-channel \\\n  containrrr/watchtower\n
"},{"location":"notifications/#microsoft_teams","title":"Microsoft Teams","text":"

To receive notifications in MSTeams channel, add msteams to the --notifications option or the WATCHTOWER_NOTIFICATIONS environment variable.

Additionally, you should set the MSTeams webhook URL using the --notification-msteams-hook option or the WATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL environment variable. This option can also reference a file, in which case the contents of the file are used.

MSTeams notifier could send keys/values filled by log.WithField or log.WithFields as MSTeams message facts. To enable this feature add --notification-msteams-data flag or set WATCHTOWER_NOTIFICATION_MSTEAMS_USE_LOG_DATA=true environment variable.

Example:

docker run -d \\\n  --name watchtower \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -e WATCHTOWER_NOTIFICATIONS=msteams \\\n  -e WATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL=\"https://outlook.office.com/webhook/xxxxxxxx@xxxxxxx/IncomingWebhook/yyyyyyyy/zzzzzzzzzz\" \\\n  -e WATCHTOWER_NOTIFICATION_MSTEAMS_USE_LOG_DATA=true \\\n  containrrr/watchtower\n
"},{"location":"notifications/#gotify","title":"Gotify","text":"

To push a notification to your Gotify instance, register a Gotify app and specify the Gotify URL and app token:

docker run -d \\\n  --name watchtower \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -e WATCHTOWER_NOTIFICATIONS=gotify \\\n  -e WATCHTOWER_NOTIFICATION_GOTIFY_URL=\"https://my.gotify.tld/\" \\\n  -e WATCHTOWER_NOTIFICATION_GOTIFY_TOKEN=\"SuperSecretToken\" \\\n  containrrr/watchtower\n

-e WATCHTOWER_NOTIFICATION_GOTIFY_TOKEN or --notification-gotify-token can also reference a file, in which case the contents of the file are used.

If you want to disable TLS verification for the Gotify instance, you can use either -e WATCHTOWER_NOTIFICATION_GOTIFY_TLS_SKIP_VERIFY=true or --notification-gotify-tls-skip-verify.

"},{"location":"private-registries/","title":"Private registries","text":"

Watchtower supports private Docker image registries. In many cases, accessing a private registry requires a valid username and password (i.e., credentials). In order to operate in such an environment, watchtower needs to know the credentials to access the registry.

The credentials can be provided to watchtower in a configuration file called config.json. There are two ways to generate this configuration file:

"},{"location":"private-registries/#create_the_configuration_file_manually","title":"Create the configuration file manually","text":"

Create a new configuration file with the following syntax and a base64 encoded username and password auth string:

{\n    \"auths\": {\n        \"<REGISTRY_NAME>\": {\n            \"auth\": \"XXXXXXX\"\n        }\n    }\n}\n

<REGISTRY_NAME> needs to be replaced by the name of your private registry (e.g., my-private-registry.example.org).

Using private images on Docker Hub

To access private repositories on Docker Hub, <REGISTRY_NAME> should be https://index.docker.io/v1/. In this special case, the registry domain does not have to be specified in docker run or docker-compose. Like Docker, Watchtower will use the Docker Hub registry and its credentials when no registry domain is specified.

Watchtower will recognize credentials with <REGISTRY_NAME> index.docker.io, but the Docker CLI will not.

Using a private registry on a local host

To use a private registry hosted locally, make sure to correctly specify the registry host in both config.json and the docker run command or docker-compose file. Valid hosts are localhost[:PORT], HOST:PORT, or any multi-part domain.name or IP-address with or without a port.

Examples: * localhost -> localhost/myimage * 127.0.0.1 -> 127.0.0.1/myimage:mytag * host.domain -> host.domain/myorganization/myimage * other-lan-host:80 -> other-lan-host:80/imagename:latest

The required auth string can be generated as follows:

echo -n 'username:password' | base64\n

Username and Password for GCloud

For gcloud, we'll use _json_key as our username and the content of gcloudauth.json as the password.

bash echo -n \"_json_key:$(cat gcloudauth.json)\" | base64 -w0\n

When the watchtower Docker container is started, the created configuration file (<PATH>/config.json in this example) needs to be passed to the container:

docker run [...] -v <PATH>/config.json:/config.json containrrr/watchtower\n
"},{"location":"private-registries/#share_the_docker_configuration_file","title":"Share the Docker configuration file","text":"

To pull an image from a private registry, docker login needs to be called first, to get access to the registry. The provided credentials are stored in a configuration file called <PATH_TO_HOME_DIR>/.docker/config.json. This configuration file can be directly used by watchtower. In this case, the creation of an additional configuration file is not necessary.

When the Docker container is started, pass the configuration file to watchtower:

docker run [...] -v <PATH_TO_HOME_DIR>/.docker/config.json:/config.json containrrr/watchtower\n

When creating the watchtower container via docker-compose, use the following lines:

version: \"3.4\"\nservices:\n  watchtower:\n    image: containrrr/watchtower:latest\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n      - <PATH_TO_HOME_DIR>/.docker/config.json:/config.json\n  ...\n
"},{"location":"private-registries/#docker_config_path","title":"Docker Config path","text":"

By default, watchtower will look for the config.json file in /, but this can be changed by setting the DOCKER_CONFIG environment variable to the directory path where your config is located. This is useful for setups where the config.json file is changed while the watchtower instance is running, as the changes will not be picked up for a mounted file if the inode changes. Example usage:

version: \"3.4\"\n\nservices: \n  watchtower:\n    image: containrrr/watchtower\n    environment:\n        DOCKER_CONFIG: /config\n    volumes:\n      - /etc/watchtower/config/:/config/\n      - /var/run/docker.sock:/var/run/docker.sock\n
"},{"location":"private-registries/#credential_helpers","title":"Credential helpers","text":"

Some private Docker registries (the most prominent probably being AWS ECR) use non-standard ways of authentication. To be able to use this together with watchtower, we need to use a credential helper.

To keep the image size small we've decided to not include any helpers in the watchtower image, instead we'll put the helper in a separate container and mount it using volumes.

"},{"location":"private-registries/#example","title":"Example","text":"

Example implementation for use with amazon-ecr-credential-helper:

Use the dockerfile below to build the amazon-ecr-credential-helper, in a volume that may be mounted onto your watchtower container.

  1. Create the Dockerfile (contents below):

    FROM golang:1.17\n\nENV GO111MODULE off\nENV CGO_ENABLED 0\nENV REPO github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login\n\nRUN go get -u $REPO\n\nRUN rm /go/bin/docker-credential-ecr-login\n\nRUN go build \\\n -o /go/bin/docker-credential-ecr-login \\\n /go/src/$REPO\n\nWORKDIR /go/bin/\n

  2. Use the following commands to build the aws-ecr-dock-cred-helper and store it's output in a volume:

    # Create a volume to store the command (once built)\ndocker volume create helper \n\n# Build the container\ndocker build -t aws-ecr-dock-cred-helper .\n\n# Build the command and store it in the new volume in the /go/bin directory.\ndocker run  -d --rm --name aws-cred-helper \\\n  --volume helper:/go/bin aws-ecr-dock-cred-helper\n

  3. Create a configuration file for docker, and store it in $HOME/.docker/config.json (replace the placeholders with your AWS Account ID and with your AWS ECR Region):

    {\n   \"credsStore\" : \"ecr-login\",\n   \"HttpHeaders\" : {\n     \"User-Agent\" : \"Docker-Client/19.03.1 (XXXXXX)\"\n   },\n   \"auths\" : {\n     \"<AWS_ACCOUNT_ID>.dkr.ecr.<AWS_ECR_REGION>.amazonaws.com\" : {}\n   },\n   \"credHelpers\": {\n     \"<AWS_ACCOUNT_ID>.dkr.ecr.<AWS_ECR_REGION>.amazonaws.com\" : \"ecr-login\"\n   }\n}\n
  4. Create a docker-compose file (as an example) to help launch the container:

    version: \"3.4\"\nservices:\n # Check for new images and restart things if a new image exists\n # for any of our containers.\n watchtower:\n   image: containrrr/watchtower:latest\n   volumes:\n     - /var/run/docker.sock:/var/run/docker.sock\n     - .docker/config.json:/config.json\n     - helper:/go/bin\n   environment:\n     - HOME=/\n     - PATH=$PATH:/go/bin\n     - AWS_REGION=us-west-1\nvolumes:\n helper: \n   external: true\n

  5. A few additional notes:

    1. With docker-compose the volume (helper, in this case) MUST be set to external: true, otherwise docker-compose will preface it with the directory name.

    2. Note that \"credsStore\" : \"ecr-login\" is needed - and in theory if you have that you can remove the credHelpers section

    3. I have this running on an EC2 instance that has credentials assigned to it - so no keys are needed; however, you may need to include the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables as well.

    4. An alternative to adding the various variables is to create a ~/.aws/config and ~/.aws/credentials files and place the settings there, then mount the ~/.aws directory to / in the container.

    "},{"location":"remote-hosts/","title":"Remote hosts","text":"

    By default, watchtower is set-up to monitor the local Docker daemon (the same daemon running the watchtower container itself). However, it is possible to configure watchtower to monitor a remote Docker endpoint. When starting the watchtower container you can specify a remote Docker endpoint with either the --host flag or the DOCKER_HOST environment variable:

    docker run -d \\\n  --name watchtower \\\n  containrrr/watchtower --host \"tcp://10.0.1.2:2375\"\n

    or

    docker run -d \\\n  --name watchtower \\\n  -e DOCKER_HOST=\"tcp://10.0.1.2:2375\" \\\n  containrrr/watchtower\n

    Note in both of the examples above that it is unnecessary to mount the /var/run/docker.sock into the watchtower container.

    "},{"location":"running-multiple-instances/","title":"Running multiple instances","text":"

    By default, Watchtower will clean up other instances and won't allow multiple instances running on the same Docker host or swarm. It is possible to override this behavior by defining a scope to each running instance.

    Note

    To define an instance monitoring scope, use the --scope argument or the WATCHTOWER_SCOPE environment variable on startup and set the com.centurylinklabs.watchtower.scope label with the same value for the containers you want to include in this instance's scope (including the instance itself).

    For example, in a Docker Compose config file:

    version: '3'\n\nservices:\n  app-with-scope:\n    image: myapps/monitored-by-watchtower\n    labels: [ \"com.centurylinklabs.watchtower.scope=myscope\" ]\n\n  scoped-watchtower:\n    image: containrrr/watchtower\n    volumes: [ \"/var/run/docker.sock:/var/run/docker.sock\" ]\n    command: --interval 30 --scope myscope\n    labels: [ \"com.centurylinklabs.watchtower.scope=myscope\" ] \n\n  unscoped-app-a:\n    image: myapps/app-a\n\n  unscoped-app-b:\n    image: myapps/app-b\n    labels: [ \"com.centurylinklabs.watchtower.scope=none\" ]\n\n  unscoped-app-c:\n    image: myapps/app-b\n    labels: [ \"com.centurylinklabs.watchtower.scope=\" ]\n\n  unscoped-watchtower:\n    image: containrrr/watchtower\n    volumes: [ \"/var/run/docker.sock:/var/run/docker.sock\" ]\n    command: --interval 30 --scope none\n
    "},{"location":"secure-connections/","title":"Secure connections","text":"

    Watchtower is also capable of connecting to Docker endpoints which are protected by SSL/TLS. If you've used docker-machine to provision your remote Docker host, you simply need to volume mount the certificates generated by docker-machine into the watchtower container and optionally specify --tlsverify flag.

    The docker-machine certificates for a particular host can be located by executing the docker-machine env command for the desired host (note the values for the DOCKER_HOST and DOCKER_CERT_PATH environment variables that are returned from this command). The directory containing the certificates for the remote host needs to be mounted into the watchtower container at /etc/ssl/docker.

    With the certificates mounted into the watchtower container you need to specify the --tlsverify flag to enable verification of the certificate:

    docker run -d \\\n  --name watchtower \\\n  -e DOCKER_HOST=$DOCKER_HOST \\\n  -e DOCKER_CERT_PATH=/etc/ssl/docker \\\n  -v $DOCKER_CERT_PATH:/etc/ssl/docker \\\n  containrrr/watchtower --tlsverify\n
    "},{"location":"stop-signals/","title":"Stop signals","text":"

    When watchtower detects that a running container needs to be updated it will stop the container by sending it a SIGTERM signal. If your container should be shutdown with a different signal you can communicate this to watchtower by setting a label named com.centurylinklabs.watchtower.stop-signal with the value of the desired signal.

    This label can be coded directly into your image by using the LABEL instruction in your Dockerfile:

    LABEL com.centurylinklabs.watchtower.stop-signal=\"SIGHUP\"\n

    Or, it can be specified as part of the docker run command line:

    docker run -d --label=com.centurylinklabs.watchtower.stop-signal=SIGHUP someimage\n
    "},{"location":"template-preview/","title":"Template preview","text":"
    loading wasm...
    {{- with .Report -}} {{- if ( or .Updated .Failed ) -}} {{len .Scanned}} Scanned, {{len .Updated}} Updated, {{len .Failed}} Failed {{- range .Updated}} - {{.Name}} ({{.ImageName}}): {{.CurrentImageID.ShortID}} updated to {{.LatestImageID.ShortID}} {{- end -}} {{- range .Fresh}} - {{.Name}} ({{.ImageName}}): {{.State}} {{- end -}} {{- range .Skipped}} - {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}} {{- end -}} {{- range .Failed}} - {{.Name}} ({{.ImageName}}): {{.State}}: {{.Error}} {{- end -}} {{- end -}} {{- end -}} {{- if (and .Entries .Report) }} Logs: {{ end -}} {{range .Entries -}}{{.Time.Format \"2006-01-02T15:04:05Z07:00\"}} [{{.Level}}] {{.Message}}{{\"\\n\"}}{{- end -}} Container report Skipped: Scanned: Updated: Failed: Fresh: Stale: Log entries Error: Warning: Info: Debug: Update preview
    "},{"location":"updating/","title":"Updating","text":""},{"location":"updating/#updating_watchtower","title":"Updating Watchtower","text":"

    If watchtower is monitoring the same Docker daemon under which the watchtower container itself is running (i.e. if you volume-mounted /var/run/docker.sock into the watchtower container) then it has the ability to update itself. If a new version of the containrrr/watchtower image is pushed to the Docker Hub, your watchtower will pull down the new image and restart itself automatically.

    "},{"location":"usage-overview/","title":"Usage overview","text":"

    Watchtower is itself packaged as a Docker container so installation is as simple as pulling the containrrr/watchtower image. If you are using ARM based architecture, pull the appropriate containrrr/watchtower:armhf-<tag> image from the containrrr Docker Hub.

    Since the watchtower code needs to interact with the Docker API in order to monitor the running containers, you need to mount /var/run/docker.sock into the container with the -v flag when you run it.

    Run the watchtower container with the following command:

    docker run -d \\\n  --name watchtower \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  containrrr/watchtower\n

    If pulling images from private Docker registries, supply registry authentication credentials with the environment variables REPO_USER and REPO_PASS or by mounting the host's docker config file into the container (at the root of the container filesystem /).

    Passing environment variables:

    docker run -d \\\n  --name watchtower \\\n  -e REPO_USER=username \\\n  -e REPO_PASS=password \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  containrrr/watchtower container_to_watch --debug\n

    Also check out this Stack Overflow answer for more options on how to pass environment variables.

    Alternatively if you 2FA authentication setup on Docker Hub then passing username and password will be insufficient. Instead you can run docker login to store your credentials in $HOME/.docker/config.json and then mount this config file to make it available to the Watchtower container:

    docker run -d \\\n  --name watchtower \\\n  -v $HOME/.docker/config.json:/config.json \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  containrrr/watchtower container_to_watch --debug\n

    Changes to config.json while running

    If you mount config.json in the manner above, changes from the host system will (generally) not be propagated to the running container. Mounting files into the Docker daemon uses bind mounts, which are based on inodes. Most applications (including docker login and vim) will not directly edit the file, but instead make a copy and replace the original file, which results in a new inode which in turn breaks the bind mount. As a workaround, you can create a symlink to your config.json file and then mount the symlink in the container. The symlinked file will always have the same inode, which keeps the bind mount intact and will ensure changes to the original file are propagated to the running container (regardless of the inode of the source file!).

    If you mount the config file as described above, be sure to also prepend the URL for the registry when starting up your watched image (you can omit the https://). Here is a complete docker-compose.yml file that starts up a docker container from a private repo on the GitHub Registry and monitors it with watchtower. Note the command argument changing the interval to 30s rather than the default 24 hours.

    version: \"3\"\nservices:\n  cavo:\n    image: ghcr.io/<org>/<image>:<tag>\n    ports:\n      - \"443:3443\"\n      - \"80:3080\"\n  watchtower:\n    image: containrrr/watchtower\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n      - /root/.docker/config.json:/config.json\n    command: --interval 30\n
    "}]}