Skip to content

Commit 0fbde7d

Browse files
committed
fixed requested changes: Check if container is running before shutting down to avoid error message #3488
1 parent 7bd413d commit 0fbde7d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/start_container.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ PORT=${PORT:-8888}
44
SRC_DIR=${SRC_DIR:-`pwd`}
55
NOTEBOOK_DIR=${NOTEBOOK_DIR:-$SRC_DIR/notebooks}
66
TOKEN=$(openssl rand -hex 24)
7+
CONTAINER_NAME=${CONTAINER_NAME:-pymc3}
78

89
# stop and remove previous instances of the pymc3 container to avoid naming conflicts
9-
docker stop pymc3
10-
docker rm pymc3
10+
if [[ $(docker ps -q -f name=${CONTAINER_NAME}) ]]; then
11+
echo "Shutting down and removing previous instance of ${CONTAINER_NAME} container..."
12+
docker rm -f ${CONTAINER_NAME}
13+
fi
1114

1215
# note that all paths are relative to the build context, so . represents
1316
# SRC_DIR to Docker
1417
docker build \
15-
-t pymc3 \
18+
-t ${CONTAINER_NAME} \
1619
-f $SRC_DIR/scripts/Dockerfile \
1720
--build-arg SRC_DIR=. \
1821
$SRC_DIR
@@ -21,7 +24,7 @@ docker run -d \
2124
-p $PORT:8888 \
2225
-v $SRC_DIR:/home/jovyan/ \
2326
-v $NOTEBOOK_DIR:/home/jovyan/work/ \
24-
--name pymc3 pymc3 \
27+
--name ${CONTAINER_NAME} ${CONTAINER_NAME} \
2528
start-notebook.sh --NotebookApp.token=${TOKEN}
2629

2730
if [[ $* != *--no-browser* ]]; then

0 commit comments

Comments
 (0)