Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env bash
set -e
IMAGE="URL"
CID=$(sudo docker ps | grep $IMAGE | awk '{print $1}')
sudo docker pull $IMAGE
for im in $CID
do
LATEST=`sudo docker inspect --format "{{.Id}}" $IMAGE`
RUNNING=`sudo docker inspect --format "{{.Image}}" $im`
NAME=`sudo docker inspect --format '{{.Name}}' $im | sed "s/\///g"`
echo "Latest:" $LATEST
echo "Running:" $RUNNING
if [ "$RUNNING" != "$LATEST" ];then
echo "upgrading $NAME"
sudo docker stop $NAME
sudo docker rmi -f $RUNNING
sudo docker run -d -p 80:80 $IMAGE
sudo docker rm $(sudo docker ps -a -q)
else
echo "$NAME up to date"
fi
done
@likejazz

This comment has been minimized.

Copy link
Owner Author

commented Dec 13, 2018

The latest version remaining on the server. This version is also no longer in use.

sudo docker pull $IMAGE
for im in $CID
do
    LATEST=`sudo docker inspect --format "{{.Id}}" $IMAGE`
    RUNNING=`sudo docker inspect --format "{{.Image}}" $im`
    NAME=`sudo docker inspect --format '{{.Name}}' $im | sed "s/\///g"`
    echo "Latest:" $LATEST
    echo "Running:" $RUNNING
    if [ "$RUNNING" != "$LATEST" ];then
        echo "upgrading $NAME"
        sudo docker stop $NAME
        sudo docker rmi -f $RUNNING
        sudo docker run -d -v /home/deploy/simpson:/simpson/simpson -p 5000:5000 $IMAGE
        sudo docker rm $(sudo docker ps -a -q)
    else
        echo "$NAME up to date"
    fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.