<p>Watchtower can send notifications when containers are updated. Notifications are sent via hooks in the logging system, <ahref="http://github.com/sirupsen/logrus">logrus</a>.
The types of notifications to send are set by passing a comma-separated list of values to the <code>--notifications</code> option (or corresponding environment variable <code>WATCHTOWER_NOTIFICATIONS</code>), which has the following valid values:</p>
<p>There is currently a <ahref="https://github.com/spf13/viper/issues/380">bug</a> in Viper, 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, as <code>WATCHTOWER_NOTIFICATIONS="slack msteams"</code></p>
<p>If you're a <code>docker-compose</code> user, make sure to specify environment variables' values in your <code>.yml</code> file without double quotes (<code>"</code>). </p>
<p>This prevents unexpected errors when watchtower starts.</p>
<li><code>--notifications-level</code> (env. <code>WATCHTOWER_NOTIFICATIONS_LEVEL</code>): Controls the log level which is used for the notifications. If omitted, the default log level is <code>info</code>. Possible values are: <code>panic</code>, <code>fatal</code>, <code>error</code>, <code>warn</code>, <code>info</code>, <code>debug</code> or <code>trace</code>.</li>
<li>Watchtower will post a notification every time it is started. This behavior <ahref="https://containrrr.github.io/watchtower/arguments/#without_sending_a_startup_message">can be changed</a> with an argument. </li>
<p>To receive notifications by email, the following command-line options, or their corresponding environment variables, can be set:</p>
<ul>
<li><code>--notification-email-from</code> (env. <code>WATCHTOWER_NOTIFICATION_EMAIL_FROM</code>): The e-mail address from which notifications will be sent.</li>
<li><code>--notification-email-to</code> (env. <code>WATCHTOWER_NOTIFICATION_EMAIL_TO</code>): The e-mail address to which notifications will be sent.</li>
<li><code>--notification-email-server</code> (env. <code>WATCHTOWER_NOTIFICATION_EMAIL_SERVER</code>): The SMTP server to send e-mails through.</li>
<li><code>--notification-email-server-tls-skip-verify</code> (env. <code>WATCHTOWER_NOTIFICATION_EMAIL_SERVER_TLS_SKIP_VERIFY</code>): Do not verify the TLS certificate of the mail server. This should be used only for testing.</li>
<li><code>--notification-email-server-port</code> (env. <code>WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT</code>): The port used to connect to the SMTP server to send e-mails through. Defaults to <code>25</code>.</li>
<li><code>--notification-email-server-user</code> (env. <code>WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER</code>): The username to authenticate with the SMTP server with.</li>
<li><code>--notification-email-server-password</code> (env. <code>WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD</code>): The password to authenticate with the SMTP server with. Can also reference a file, in which case the contents of the file are used.</li>
<li><code>--notification-email-delay</code> (env. <code>WATCHTOWER_NOTIFICATION_EMAIL_DELAY</code>): Delay before sending notifications expressed in seconds.</li>
<li><code>--notification-email-subjecttag</code> (env. <code>WATCHTOWER_NOTIFICATION_EMAIL_SUBJECTTAG</code>): Prefix to include in the subject tag. Useful when running multiple watchtowers.</li>
<p>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 <code>docker-compose.yml</code> might be a good start for you.</p>
<p>The following example assumes, that your domain is called <code>your-domain.com</code> and that you are going to use a certificate valid for <code>smtp.your-domain.com</code>. This hostname has to be used as <code>WATCHTOWER_NOTIFICATION_EMAIL_SERVER</code> otherwise the TLS connection is going to fail with <code>Failed to send notification email</code> or <code>connect: connection refused</code>. 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 <ahref="https://hub.docker.com/r/freinet/postfix-relay">freinet/postfix-relay</a>.</p>
<p>If watchtower is monitoring the same Docker daemon under which the watchtower container itself is running (i.e. if you volume-mounted <em>/var/run/docker.sock</em> into the watchtower container) then it has the ability to update itself. If a new version of the <em>containrrr/watchtower</em> image is pushed to the Docker Hub, your watchtower will pull down the new image and restart itself automatically.</p>
<p>To receive notifications in Slack, add <code>slack</code> to the <code>--notifications</code> option or the <code>WATCHTOWER_NOTIFICATIONS</code> environment variable.</p>
<p>Additionally, you should set the Slack webhook URL using the <code>--notification-slack-hook-url</code> option or the <code>WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL</code> environment variable. This option can also reference a file, in which case the contents of the file are used.</p>
<p>By default, watchtower will send messages under the name <code>watchtower</code>, you can customize this string through the <code>--notification-slack-identifier</code> option or the <code>WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER</code> environment variable.</p>
<p>Other, optional, variables include:</p>
<ul>
<li><code>--notification-slack-channel</code> (env. <code>WATCHTOWER_NOTIFICATION_SLACK_CHANNEL</code>): A string which overrides the webhook's default channel. Example: #my-custom-channel.</li>
<li><code>--notification-slack-icon-emoji</code> (env. <code>WATCHTOWER_NOTIFICATION_SLACK_ICON_EMOJI</code>): An <ahref="https://www.webpagefx.com/tools/emoji-cheat-sheet/">emoji code</a> string to use in place of the default icon.</li>
<li><code>--notification-slack-icon-url</code> (env. <code>WATCHTOWER_NOTIFICATION_SLACK_ICON_URL</code>): An icon image URL string to use in place of the default icon.</li>
<p>To receive notifications in MSTeams channel, add <code>msteams</code> to the <code>--notifications</code> option or the <code>WATCHTOWER_NOTIFICATIONS</code> environment variable.</p>
<p>Additionally, you should set the MSTeams webhook URL using the <code>--notification-msteams-hook</code> option or the <code>WATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL</code> environment variable. This option can also reference a file, in which case the contents of the file are used.</p>
<p>MSTeams notifier could send keys/values filled by <code>log.WithField</code> or <code>log.WithFields</code> as MSTeams message facts. To enable this feature add <code>--notification-msteams-data</code> flag or set <code>WATCHTOWER_NOTIFICATION_MSTEAMS_USE_LOG_DATA=true</code> environment variable.</p>
<p><code>-e WATCHTOWER_NOTIFICATION_GOTIFY_TOKEN</code> or <code>--notification-gotify-token</code> can also reference a file, in which case the contents of the file are used.</p>
<p>If you want to disable TLS verification for the Gotify instance, you can use either <code>-e WATCHTOWER_NOTIFICATION_GOTIFY_TLS_SKIP_VERIFY=true</code> or <code>--notification-gotify-tls-skip-verify</code>. </p>
<p>To send notifications via shoutrrr, the following command-line options, or their corresponding environment variables, can be set:</p>
<ul>
<li><code>--notification-url</code> (env. <code>WATCHTOWER_NOTIFICATION_URL</code>): The shoutrrr service URL to be used.</li>
</ul>
<p>Go to <ahref="https://containrrr.github.io/shoutrrr/services/overview">containrrr.github.io/shoutrrr/services/overview</a> to learn more about the different service URLs you can use.
You can define multiple services by space separating the URLs. (See example below)</p>
<p>You can customize the message posted by setting a template.</p>
<ul>
<li><code>--notification-template</code> (env. <code>WATCHTOWER_NOTIFICATION_TEMPLATE</code>): The template used for the message.</li>
</ul>
<p>The template is a Go <ahref="https://golang.org/pkg/text/template/">template</a> and the you format a list of <ahref="https://pkg.go.dev/github.com/sirupsen/logrus?tab=doc#Entry">log entries</a>.</p>
<p>The default value if not set is <code>{{range .}}{{.Message}}{{println}}{{end}}</code>. The example below uses a template that also outputs timestamp and log level.</p>
<scriptsrc="../assets/javascripts/bundle.f81dfb4d.min.js"></script><scriptid="__lang"type="application/json">{"clipboard.copy":"Copy to clipboard","clipboard.copied":"Copied to clipboard","search.config.lang":"en","search.config.pipeline":"trimmer, stopWordFilter","search.config.separator":"[\\s\\-]+","search.placeholder":"Search","search.result.placeholder":"Type to start searching","search.result.none":"No matching documents","search.result.one":"1 matching document","search.result.other":"# matching documents","search.result.more.one":"1 more on this page","search.result.more.other":"# more on this page","search.result.term.missing":"Missing"}</script>