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.
- A 16 megabyte limit is set on the container, in this instance.
- I’ve added a hostname for this container because Watchtower sends emails with the hostname of the Watchtower Docker container in the subject line. By setting my own hostname instead of the default Docker generated hostname, I can glance at the email and see which of my hosts containers have just been updated.
- Email notifications are configured using the container environment variables using the -e flags. These can be omitted if you don’t want any notifications.
docker run -d \ --name watchtower \ --hostname=azure.dockerhost001 \ --restart=unless-stopped \ --memory=16mb \ -v /var/run/docker.sock:/var/run/docker.sock \ -e WATCHTOWER_NOTIFICATIONS=email \ -e [email protected] \ -e [email protected] \ -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER=your.smtp.server \ -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=your.smtp.username \ -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=your.smtp.password \ v2tec/watchtower \ --cleanup