Update and Cleanup
containrrr/watchtower
is a service that monitors Docker images for updates, automatically applying them to running containers.
Automatic image updates + cleanup
compose.yaml
services:
watchtower:
image: containrrr/watchtower:latest
# Automatic cleanup (removes older image pulls from wasting disk space):
environment:
- WATCHTOWER_CLEANUP=true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
Updating only specific containers
The default watchtower
service will check every 24 hours for any new image updates to pull, not only the images defined within your compose.yaml
.
The images to update can be restricted with a custom command that provides a list of containers names and other config options. Configuration is detailed in the watchtower
docs.
Manual cleanup
watchtower
also supports running on-demand with docker run
or compose.yaml
via the --run-once
option.
You can also directly invoke cleanup of Docker storage with:
docker image prune --all
docker system prune --all
(also removes unused containers, networks, build cache).- Avoid the
--all
option to only remove "dangling" content (eg: Orphaned images).