Automatically update running docker container with the latest image

Watchtower is an open-source tool that scans the running container and restarts those containers with the same parameters if it detects a newer version in the repository. It supports public such as docker hub and private repositories such as Azure Container Repository or AWS ECR

By default, Watchtower monitors all the container, but most of the time this may not be necessary. Adding a –label will mark those containers to monitor


docker run --name nginx  --label=com.centurylinklabs.watchtower.enable=true -d nginx:latest

docker run -d --name watchtower -e REPO_USER=username -e REPO_PASS=password -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --cleanup --label-enable  --interval 120

In this example, whenever the nginx repository is updated with new image with the ‘latest’ tag, our container will also be updated

Warning: Having a running container updated when there is a update to the container image is not recommended for production, unless you know what you are doing.

Leave a Reply

Your email address will not be published.