Skip to content

Commit 154dc3b

Browse files
author
Patrick M
committed
update
1 parent b9af6b2 commit 154dc3b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

_posts/2024-05-23-docker-prune-job.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ tags: ["linux", "docker"]
99
This is a helpful way to keep your containers from running out of space. Create a auto-prune cron job and put it in `etc/cron.daily`.
1010

1111
```bash
12-
nano /etc/cron.daily/docker-prune
13-
```
14-
15-
```bash
12+
cat <<EOF | sudo tee /etc/cron.daily/docker-prune
1613
#!/bin/bash
1714
18-
UUID=00000000-0000-0000-0000-0000000000
15+
UUID=00000000-0000-0000-0000-000000000000
16+
HOST=healthchecks.io
1917
20-
curl -m 5 --retry 5 https://healthchecks.io/ping/${UUID}/start &>/dev/null
18+
curl -m 5 --retry 5 https://\${HOST}/ping/\${UUID}/start
2119
docker system prune --volumes -af
22-
curl -m 5 --retry 5 https://healthchecks.io/ping/${UUID} &>/dev/null
20+
curl -m 5 --retry 5 https://\${HOST}/ping/\${UUID}
21+
EOF
22+
```
23+
24+
```bash
25+
sudo chmod +x /etc/cron.daily/docker-prune && /etc/cron.daily/docker-prune
2326
```
2427

2528
This also includes a ping out to [healthcheck.io](https://healthchecks.io), which is a really handy thing to track your cron jobs. You can also self host the service.

0 commit comments

Comments
 (0)