Skip to content

Instantly share code, notes, and snippets.

@crayzeigh
Created December 14, 2021 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crayzeigh/b1ef6102d84d4a0795066221ed4b4bdb to your computer and use it in GitHub Desktop.
Save crayzeigh/b1ef6102d84d4a0795066221ed4b4bdb to your computer and use it in GitHub Desktop.
#!/bin/bash
email="you@domain.com"
body="Start: $(date)
Checking for new images...
$(/bin/docker-compose -f /path/to/docker-compose.yml pull --no-parallel 2>&1)
Updating changed containers...
$(/bin/docker-compose -f /path/to/docker-compose.yml up -d 2>&1)
Cleaning up...
$(/bin/docker system prune -af 2>&1)
End $(date)
"
# Only receive emails if an image changed
if [[ ${body} == *"Recreating"* ]]; then
echo "${body}" | mail -s "Docker Updates Completed" ${email}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment