Last active
March 3, 2021 23:08
-
-
Save crayzeigh/64ae8512174d6049fde590dbf9130710 to your computer and use it in GitHub Desktop.
Bash Script for automated docker container updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
email="email@domain.com" | |
# All work done inside body variable to avoid unnecessary writes to disk for raspi | |
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) | |
End $(date)" | |
# Only send email if a container was updated/restarted | |
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