Skip to content

Commit 8317281

Browse files
Merge pull request #3488 from Bruschkov/docker-build-fix
remove previous instance of docker container in start_container script
2 parents 988f522 + cb5e04e commit 8317281

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scripts/start_container.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +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}
8+
9+
# stop and remove previous instances of the pymc3 container to avoid naming conflicts
10+
if [[ $(docker ps -aq -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
714

815
# note that all paths are relative to the build context, so . represents
916
# SRC_DIR to Docker
1017
docker build \
11-
-t pymc3 \
18+
-t ${CONTAINER_NAME} \
1219
-f $SRC_DIR/scripts/Dockerfile \
1320
--build-arg SRC_DIR=. \
1421
$SRC_DIR
@@ -17,7 +24,7 @@ docker run -d \
1724
-p $PORT:8888 \
1825
-v $SRC_DIR:/home/jovyan/ \
1926
-v $NOTEBOOK_DIR:/home/jovyan/work/ \
20-
--name pymc3 pymc3 \
27+
--name ${CONTAINER_NAME} ${CONTAINER_NAME} \
2128
start-notebook.sh --NotebookApp.token=${TOKEN}
2229

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

0 commit comments

Comments
 (0)