CoreOS使用systemd设置计划任务定期清理docker缓存

编辑/etc/systemd/system/ktsee-docker-cleaner.timer文件

# /etc/systemd/system/ktsee-docker-cleaner.timer

[Unit]

Description=clean docker images and containers at everyday 02:00

After=network-online.target

[Timer]

OnCalendar=*-*-* 02:00:00

# same name can ignore below

# Unit=ktsee-docker-cleaner.service

[Install]

WantedBy=multi-user.target

编辑/etc/systemd/system/ktsee-docker-cleaner.service文件

# /etc/systemd/system/ktsee-docker-cleaner.service

[Unit]

Description=clear docker images and containers

After=docker.service

Requires=docker.service

[Service]

ExecStart=/bin/sh -c "/usr/bin/docker container prune --force&&/usr/bin/docker image prune --force&&docker volume prune --force&&docker network prune --force"

[Install]

WantedBy=multi-user.target

重启并查看服务

systemctl daemon-reload

systemctl enable ktsee-docker-cleaner.timer

systemctl start ktsee-docker-cleaner.timer

systemctl list-timers

评论

Popular Posts

eXtplorer - 一个基于PHP和JavaScript的在线文件管理器

随身WiFi折腾指南: 解锁、刷机与DIY

mihomo各平台客户端下载(windows, android, macos)

常用的国内外延迟测速链接(generate_204)

Win10和Win11家庭版开启远程桌面功能RDP

坚持跑步到底有哪些改变?

十二国记 (2002)

优化PC端B站(Bilibili)免登录观看体验

Cromite - 极度注重隐私的Chromium浏览器