diff --git a/Docker-container-on-Ubuntu-16.04-LTS.md b/Docker-container-on-Ubuntu-16.04-LTS.md index 98cfcf7..7067c23 100644 --- a/Docker-container-on-Ubuntu-16.04-LTS.md +++ b/Docker-container-on-Ubuntu-16.04-LTS.md @@ -101,6 +101,27 @@ sudo docker pull linuxserver/radarr sudo systemctl restart docker-radarr ``` +If you want to automate this, you can use the following script (let it run with a systemd timer): + +```bash +#!/bin/bash + +images=( linuxserver/jackett linuxserver/radarr linuxserver/sonarr ) +containers=( jackett radarr sonarr ) +services=( docker-jackett docker-radarr docker-sonarr ) + +for ((i=0; i<${#images[*]}; i++)); do + echo "Pulling docker image: ${images[i]}" + docker pull ${images[i]} + if [[ $(docker inspect --type=image --format='{{.Id}}' ${images[i]}) != $(docker inspect --type=container --format='{{.Image}}' ${containers[i]}) ]]; then + echo "Restarting service: ${services[i]}" + systemctl restart ${services[i]} + fi +done +``` + +Modify the variables `images`, `containers` and `services` according to your system. This script will only restart a service/container if the docker image was updated by `docker pull`. + # Doing some cleanup With these commands you can do some cleanup of docker images and containers: