Bookmark

Controlled Docker Image Updates with Watchtower: Preview, Cleanup, and Stopped Containers

Watchtower monitors Docker containers for changes to their source images and can restart them with a newer image. The i12bretro tutorial separates preview, update, and cleanup; I retain all 10 source actions instead of collapsing them into an uncontrolled background command.1

Youtube video player

The original video title and author were validated with oEmbed and the video is embedded directly.2

1. Pull the Watchtower image

Step 1/10: Log into the Docker host.

Step 2/10: Pull the image:

1
docker pull containrrr/watchtower

2. Check for updates without applying them

Step 3/10: Log into the Docker host.

Step 4/10: Run one monitor-only pass, including restarting and stopped containers:

1
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once --monitor-only --include-restarting --include-stopped

This requires access to the Docker socket; the output is the Watchtower check activity. I use this pass first to see what would be affected.

3. Update running containers

Step 5/10: Log into the Docker host.

Step 6/10: Run one update pass:

1
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once

4. Update running containers and remove old images

Step 7/10: Log into the Docker host.

Step 8/10: Run cleanup:

1
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once --cleanup

--cleanup removes old images, so I check tags, persistent volumes, and rollback options before using it.

5. Update all containers, including restarting/stopped, then clean up

Step 9/10: Log into the Docker host.

Step 10/10: Run the broadest command:

1
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once --cleanup --include-restarting --include-stopped

This has the widest scope in the tutorial. I would not turn it into a cron job without backups and an exclusion policy; access to the Docker socket is effectively high-level host administration.

6. Notifications and checks

The source links separate notification instructions using environment variables. Read the corresponding Watchtower documentation before enabling them, and never put a webhook or token into public compose files or Markdown.1

After each run:

1
2
3
docker ps
docker image ls
docker logs <container-name>

Check the application, persistent volumes, and migration logs before deleting old images. The tutorial provides one-shot commands, not a schedule, retention policy, or automatic rollback; those require a separate HomeLab design.

Conclusion

The 10 steps define four behaviors: pull the image, monitor-only, update, update plus cleanup, and a final pass that includes restarting/stopped containers. I start with monitor-only, clean up only after verifying the application, and keep the Docker socket limited to a trusted host.

Sources


  1. i12bretro tutorial 0756 – Using WatchTower To Keep Docker Images Updated , revised 2025-02-23. Independently edited from the numbered HTML page; Docker commands are retained. ↩︎ ↩︎

  2. YouTube – Using WatchTower To Keep Docker Images Updated — i12bretro video, validated with oEmbed. ↩︎


0 Bình luận

Góp Ý / Bình Luận / Đánh giá