From 646b4d8b009bfa163a8e902e2bcc4bb501ec1cb7 Mon Sep 17 00:00:00 2001 From: hotio Date: Mon, 23 Jan 2017 11:05:15 +0100 Subject: [PATCH] Added update script --- Docker-container-on-Ubuntu-16.04-LTS.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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: