码迷,mamicode.com
首页 > 数据库 > 详细

Dockers 部署 MongoDB + mongo-express

时间:2019-05-05 23:38:01      阅读:400      评论:0      收藏:0      [点我收藏+]

标签:waiting   implicit   str   pen   support   api   http   from   version   

1. 拉取 Mongo 镜像

docker pull mongo:4.1.6

2.  运行镜像

docker run -d --name mongodb --volume /usr/local/mongodata:/data/db -p 27017:27017 mongo:4.1.6 --auth

技术图片

3. 创建root用户

进入 mongo

$ docker exec -it mongodb mongo
MongoDB shell version v4.1.6
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("3178ad60-401e-4c19-8575-b7ecbd21819d") }
MongoDB server version: 4.1.6
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
>

进入 admin 库并创建root用户

> use admin
switched to db admin
> show dbs
> db.createUser({user: root, pwd: 123, roles: [{role: "root", db: "admin"}]})
Successfully added user: {
        "user" : "root",
        "roles" : [
                {
                        "role" : "root",
                        "db" : "admin"
                }
        ]
}

4. 安装并与行mongo-express

$ docker run -d --name mongo-express -p 8081:8081 --link mongodb:mongo --env ME_CONFIG_MONGODB_ADMINUSERNAME=root --e
nv ME_CONFIG_MONGODB_ADMINPASSWORD=123 mongo-express
84bef6b30fd17400ae1c64618273246667a68952e02ec929bdfcfef9004c7076

5. 检查

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                      NAMES
84bef6b30fd1        mongo-express       "tini -- /docker-ent…"   44 seconds ago      Up 19 seconds       0.0.0.0:8081->8081/tcp     mongo-express
ea6b16c829ca        mongo:4.1.6         "docker-entrypoint.s…"   5 minutes ago       Up 5 minutes        0.0.0.0:27017->27017/tcp   mongodb

13607@DESKTOP-V4C6O50 MINGW64 /d/Program Files/Docker Toolbox
$ docker logs -f 84
Waiting for mongo:27017...
Welcome to mongo-express
------------------------


Mongo Express server listening at http://0.0.0.0:8081
Server is open to allow connections from anyone (0.0.0.0)
basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
Database connected
Admin Database connected

技术图片

 6. 附加

或许你用 ie 无法打开

技术图片

 

Dockers 部署 MongoDB + mongo-express

标签:waiting   implicit   str   pen   support   api   http   from   version   

原文地址:https://www.cnblogs.com/yelao/p/10816767.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!