Skip to content

Instantly share code, notes, and snippets.

@eiri
Last active May 20, 2024 15:14
Show Gist options
  • Save eiri/8ccc0b7df93bed4ab2f2d290fba5a070 to your computer and use it in GitHub Desktop.
Save eiri/8ccc0b7df93bed4ab2f2d290fba5a070 to your computer and use it in GitHub Desktop.
Cleanup after Docker nightly on Mac

Cleanup after docker nightly on Mac

or crontab in Mac style

not like normal crontab -e and 0 3 * * * /usr/bin/docker system prune -f wouldn't work

sudo touch /Library/LaunchDaemons/DockerSystemPrune.plist drop content of DockerSystemPrune.plist in it and run launchctl load -w /Library/LaunchDaemons/DockerSystemPrune.plist. Done, now every night at 3:00AM all stopped containers, unused networks, dangling images and build caches will be cleaned up.

Source: Docker Tip #32

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>DockerSystemPrue</string>
<key>Program</key>
<string>/usr/local/bin/docker system prune -f</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment