docker安装mongo和adminmongo
2019-12-16 本文已影响0人
你慧快乐
不喜欢说废话,直接上干货:
docker run -d \
-e MONGO_INITDB_ROOT_USERNAME=root \
-e MONGO_INITDB_ROOT_PASSWORD=root123456 \
-v /home/tianxiang/docker-data/mongo/db:/data/db \
-v /etc/localtime:/etc/localtime \
-v /home/tianxiang/docker-data/mongo:/usr/local/mongo \
-v /home/tianxiang/docker-data/mongo/configdb:/data/configdb \
-p 27018:27017 \
--name mongodb-4.2.1 \
--net custom \
--ip 172.18.0.9 \
mongo \
--config /usr/local/mongo/mongod.conf
可根据需要自行配置网络和映射目录
测试连接:
docker run -it --rm --network custom mongo \
mongo --host 172.18.0.9 \
-u root \
-p root123456 \
--authenticationDatabase admin \
config
安装mongo-express
mongo-expres:
docker run -it --rm \
--network custom \
--name mongo-express \
-e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" \
-e ME_CONFIG_MONGODB_SERVER="mongo" \
-e ME_CONFIG_BASICAUTH_USERNAME="admin" \
-e ME_CONFIG_BASICAUTH_PASSWORD="admin123" \
mongo-express
安装adminmongo
admin-mongo:
docker run -d -e PORT=1234 \
-e HOST=0.0.0.0 \
-e PASSWORD="admin123" \
--network custom \
--ip 172.18.0.11 \
--name adminmongo \
rainu/adminmongo
注意,一定要加上-e HOST=0.0.0.0 否则只能再容器内部访问