Skip to content

Instantly share code, notes, and snippets.

@gintsmurans
Created November 10, 2024 23:15
Show Gist options
  • Save gintsmurans/dfe0d15f8efe1588d5c54817229c099f to your computer and use it in GitHub Desktop.
Save gintsmurans/dfe0d15f8efe1588d5c54817229c099f to your computer and use it in GitHub Desktop.
Docker prune service
# /etc/systemd/system/docker-prune.service
[Unit]
Description=Daily Prune of Docker Images and Containers
Documentation=https://docs.docker.com/config/pruning/
[Service]
Type=oneshot
ExecStart=/usr/bin/docker system prune -f
ExecStartPost=/usr/bin/echo "Docker environment now as clean as a whistle, or at least cleaner than yesterday."
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/docker-prune.timer
#
# After saving run these to enable the timer:
# systemctl enable docker-prune.timer
# systemctl start docker-prune.timer
[Unit]
Description=Run Docker Prune at 3AM Daily
[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true
Unit=docker-prune.service
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment