1
0
mirror of https://github.com/stucki/docker-lineageos synced 2024-12-19 17:12:29 -05:00

Continue if "docker inspect" returns false

This commit is contained in:
Michael Stucki 2017-04-24 22:56:01 +02:00
parent 75c8df9c9e
commit 15db4220e6

4
run.sh
View File

@ -49,7 +49,7 @@ elif [[ $FORCE_BUILD = 1 ]] || ! echo "$IMAGE_EXISTS" | grep -q "$TAG"; then
docker build -t $REPOSITORY:$TAG --build-arg hostuid=$USERID --build-arg hostgid=$GROUPID . docker build -t $REPOSITORY:$TAG --build-arg hostuid=$USERID --build-arg hostgid=$GROUPID .
# After successful build, delete existing containers # After successful build, delete existing containers
IS_EXISTING=$(docker inspect -f '{{.Id}}' $CONTAINER 2>/dev/null) IS_EXISTING=$(docker inspect -f '{{.Id}}' $CONTAINER 2>/dev/null) || true
if [[ -n $IS_EXISTING ]]; then if [[ -n $IS_EXISTING ]]; then
docker rm $CONTAINER docker rm $CONTAINER
fi fi
@ -57,7 +57,7 @@ fi
# With the given name $CONTAINER, reconnect to running container, start # With the given name $CONTAINER, reconnect to running container, start
# an existing/stopped container or run a new one if one does not exist. # an existing/stopped container or run a new one if one does not exist.
IS_RUNNING=$(docker inspect -f '{{.State.Running}}' $CONTAINER 2>/dev/null) IS_RUNNING=$(docker inspect -f '{{.State.Running}}' $CONTAINER 2>/dev/null) || true
if [[ $IS_RUNNING == "true" ]]; then if [[ $IS_RUNNING == "true" ]]; then
docker attach $CONTAINER docker attach $CONTAINER
elif [[ $IS_RUNNING == "false" ]]; then elif [[ $IS_RUNNING == "false" ]]; then