Skip to content

Instantly share code, notes, and snippets.

@jeremysherriff
Created June 8, 2022 06:31
Show Gist options
  • Save jeremysherriff/2b28b30142b6155b48cb51095366c75a to your computer and use it in GitHub Desktop.
Save jeremysherriff/2b28b30142b6155b48cb51095366c75a to your computer and use it in GitHub Desktop.
Automated updating of containers via cron
#!/bin/sh
# Automated updating of containers via cron
# Leverages watchtower for auto image cleanup and robustness.
if [ -t 1 ] ; then
echo "Running in an interactive shell"
else
exec 1>/dev/null
exec 2>/dev/null
fi
docker pull containrrr/watchtower
docker run --rm --name watchtower-runonce \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--stop-timeout 30s \
--cleanup \
--rolling-restart \
--include-stopped \
--run-once \
$*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment