-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_docker.sh
executable file
·42 lines (32 loc) · 1.11 KB
/
run_docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
stop_existing_containers() {
echo "Checking for containers using port 8887..."
containers=$(docker ps -q --filter "publish=8887")
if [ -n "$containers" ]; then
echo "Stopping and removing the following containers:"
echo "$containers"
docker stop $containers
docker rm $containers
else
echo "No containers using port 8887."
fi
}
stop_existing_containers
docker build --build-arg http_proxy=http://proxy-wsa.esl.cisco.com:80 \
--build-arg https_proxy=http://proxy-wsa.esl.cisco.com:80 \
-t cisco_theme_jupyter .
if [ $? -eq 0 ]; then
echo "Docker image built successfully."
NOTEBOOKS_DIR=$(pwd)/notebooks
mkdir -p $NOTEBOOKS_DIR
container_id=$(docker run -d -p 8887:8887 -v $NOTEBOOKS_DIR:/app/notebooks cisco_theme_jupyter)
if [ $? -eq 0 ]; then
echo "Docker container started successfully."
sleep 5
echo "You can access your environment at http://127.0.0.1:8887"
else
echo "Failed to start Docker container."
fi
else
echo "Failed to build Docker image."
fi