Skip to content

Instantly share code, notes, and snippets.

@AstraLuma
Last active August 26, 2025 21:51
Show Gist options
  • Save AstraLuma/d22c2ce78fb0744e469060dadf5020f7 to your computer and use it in GitHub Desktop.
Save AstraLuma/d22c2ce78fb0744e469060dadf5020f7 to your computer and use it in GitHub Desktop.
docker+systemd
[Unit]
Description=Compose app %i
Requires=docker.socket
[Install]
WantedBy=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/etc/compose/%i
ExecStart=docker compose --ansi never up -d
ExecStop=docker compose --ansi never stop
ExecReload=docker compose --ansi never up -d --build
{
"log-driver": "journald"
}
[Unit]
Description=Docker GC
Requires=docker.socket
[Service]
Type=oneshot
ExecStart=docker system prune --all --force --filter "until=168h"
[Unit]
Description=Daily Docker GC
After=docker.socket
[Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
[Journal]
Storage=persist
MaxRetentionSec=90day
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment