diff --git a/launch.sh b/launch.sh index 7930ae9..a80502d 100755 --- a/launch.sh +++ b/launch.sh @@ -186,14 +186,12 @@ create() { dev() { initial_start - # Run existing Docker container, otherwise create a new one - GISSMO_RUNNING=$($docker_cmd inspect --format="{{ .State.Running }}" ${GISSMO_DOCKER_NAME} 2> /dev/null) - if [ $? -eq 1 ]; then - $docker_cmd run -it --rm --link ${POSTGRES_DOCKER_NAME}:db -p ${GISSMO_DOCKER_PORT}:8000 -v ${GISSMO_DIR}:/opt/gissmo --name ${GISSMO_DOCKER_NAME} gissmo:${GISSMO_VERSION} ${ARGS:='development'} || error_and_quit "Failed to create and launch ${GISSMO_DOCKER_NAME} container." - else - error_and_quit "${GISSMO_DOCKER_NAME} is already launched! If you need -another name please set GISSMO_DOCKER_NAME in configuration file." + PORT_PARAM=" -p ${GISSMO_DOCKER_PORT}:8000 " + GISSMO_DEV_RUNNING_PORT=$(nc -z 127.0.0.1 ${GISSMO_DOCKER_PORT} &> /dev/null; echo $?) + if [ $GISSMO_DEV_RUNNING_PORT -eq 0 ]; then + PORT_PARAM=" -P " fi + $docker_cmd run -it --rm --link ${POSTGRES_DOCKER_NAME}:db ${PORT_PARAM} -v ${GISSMO_DIR}:/opt/gissmo gissmo:${GISSMO_VERSION} ${ARGS:='development'} || error_and_quit "Failed to create and launch ${GISSMO_DOCKER_NAME} container." } test_backup() {