Mongo install with Docker Cookie

mongo镜像为moingo数据库本体

mongo-express 为mongo web admin工具

分别创建mongo与express

Step01 创建网络(非必须)

1
2
docker network create ej-network
docker network ls

Step02 创建 MongoDB 与 Mongo Express

  • 也可以不指定网络
  • 端口为27017
  • 帐号密码为root/root
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
docker run -d --network ej-network \
--name ej-mongo \
-p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=root \
-e MONGO_INITDB_ROOT_PASSWORD=root \
mongo:4.2

docker run -d --network ej-network\
--name ej-mongo-express \
-p 8081:8081 \
-e ME_CONFIG_MONGODB_SERVER=ej-mongo \
-e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" \
-e ME_CONFIG_BASICAUTH_USERNAME="root" \
-e ME_CONFIG_BASICAUTH_PASSWORD="root" \
-e ME_CONFIG_MONGODB_ADMINUSERNAME="root" \
-e ME_CONFIG_MONGODB_ADMINPASSWORD="root" \
mongo-express

Use Docker MongoDB Client

1
docker run -it --link some-mongo:mongo --rm mongo sh -c 'exec mongo "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT/test"'

Install MongoDB at Ubuntu

1
2
apt-get install mongodb
apt-get install mongodb-clients

Install MongoDB in MacOS

1
brew info mongodb