-
Notifications
You must be signed in to change notification settings - Fork 1
/
mongodb.sh
executable file
·31 lines (25 loc) · 1 KB
/
mongodb.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
#!/bin/bash
read -p "Time Zone: " tz
read -p "Enter MongoDB Root Username: " username
read -p "Enter MongoDB Root Password: " password
echo "Waiting to pull the latest image..."
sudo docker pull mongo:latest || error "Failed to pull MongoDB docker image!"
sudo docker run -d \
--name mongodb \
-v /var/lib/mongodb:/etc/mongo \
-e TZ=${tz} \
-e MONGO_INITDB_ROOT_USERNAME=${username} \
-e MONGO_INITDB_ROOT_PASSWORD=${password} \
--restart unless-stopped \
mongo:latest || error "Failed to run MongoDB docker container!"
sudo docker pull mongo:latest || error "Failed to pull MongoDB_Express docker image!"
sudo docker run -d \
--name mongo-express \
-p 8081:8081 \
-v /var/lib/mongodb:/etc/mongo \
-e TZ=${tz} \
-e ME_CONFIG_MONGODB_ADMINUSERNAME=${username} \
-e ME_CONFIG_MONGODB_ADMINPASSWORD=${password} \
-e ME_CONFIG_MONGODB_URL: mongodb://${username}:${password}@mongo:27017/
--restart unless-stopped \
mongo-express:latest || error "Failed to run MongoDB_Express docker container!"