feat: Kill previous container for the same project if it exists

This commit is contained in:
Glenn Y. Rolland 2022-11-02 20:55:53 +01:00
parent 6b315b2f44
commit aee774329f

View file

@ -3,6 +3,7 @@
# Set defaults
BASEDIR="$(pwd)"
BASEHASH="$(echo "$BASEDIR" |sha256sum |head -c7)"
ACTION="watch"
VERBOSITY="0"
DOCKER_IMAGE=glenux/teaching-boilerplate:latest
@ -104,7 +105,17 @@ fi
if [ "$VERBOSITY" -gt 0 ]; then
set -x
fi
DOCKER_NAME="gx-teaching-$BASEHASH"
DOCKER_CID="$(docker ps -f "name=$DOCKER_NAME" -q)"
if [ -n "$DOCKER_CID" ]; then
docker kill "$DOCKER_NAME"
fi
docker run -i $DOCKER_OPT_TTY \
--name "$DOCKER_NAME" \
--rm \
--shm-size=1gb \
-e "EXT_UID=$(id -u)" \
-e "EXT_GID=$(id -g)" \