Browse Source

make IP a parameter

Charles Reid 1 year ago
parent
commit
3c9c43bd28
1 changed files with 7 additions and 3 deletions
  1. 7
    3
      run_mongodb.sh

+ 7
- 3
run_mongodb.sh View File

@@ -7,10 +7,12 @@
7 7
 #
8 8
 # Can bind the interface to an IP at the docker layer:
9 9
 #
10
-#     -p 127.0.0.1:27017:27017
10
+#     -p <bind-ip>:27017:27017
11 11
 #
12 12
 # http://charlesreid1.com/wiki/Docker/Basics
13 13
 
14
+HOSTIP="10.6.0.2"
15
+
14 16
 debug=false
15 17
 #debug=true
16 18
 
@@ -19,8 +21,9 @@ docker ps -qa | xargs docker rm
19 21
 if [ "$debug" == true ]; then
20 22
 
21 23
     docker run \
24
+        --rm \
22 25
         --name happy_mongo \
23
-        -p 127.0.0.1:27017:27017 \
26
+        -p ${HOSTIP}:27017:27017 \
24 27
         -v /opt/mongodb:/data \
25 28
         -ti jupitermongo \
26 29
         /bin/bash
@@ -28,8 +31,9 @@ if [ "$debug" == true ]; then
28 31
 else
29 32
 
30 33
     docker run \
34
+        --rm \
31 35
         --name happy_mongo \
32
-        -p 127.0.0.1:27017:27017 \
36
+        -p ${HOSTIP}:27017:27017 \
33 37
         -v /opt/mongodb:/data \
34 38
         -d \
35 39
         -ti jupitermongo