Auto retrieve docker image tag
authorSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 13 Sep 2017 16:22:37 +0000 (18:22 +0200)
committerSebastien Douheret <sebastien.douheret@iot.bzh>
Wed, 13 Sep 2017 19:47:52 +0000 (21:47 +0200)
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
scripts/xds-docker-create-container.sh

index 52dfda3..0adc2d9 100755 (executable)
@@ -30,6 +30,16 @@ VERSION=4.0
 DOCKER_USER=devel
 
 DEFIMAGE=$REGISTRY/$REPO/$NAME-$FLAVOUR:$VERSION
+docker images |grep $DEFIMAGE 2>&1 > /dev/null
+if [ "$?" = "1" ]; then
+    VERSION=`docker images $REGISTRY/$REPO/$NAME-$FLAVOUR:* --format "{{.Tag}}"`
+    if [ "$VERSION" = "" ]; then
+        echo "ERROR: cannot automatically retrieve image tag for $REGISTRY/$REPO/$NAME-$FLAVOUR"
+        exit 1
+    fi
+    DEFIMAGE=$REGISTRY/$REPO/$NAME-$FLAVOUR:$VERSION
+fi
+
 
 function usage() {
        echo "Usage: $(basename $0) <instance ID> [image name]"  >&2