Docker下使用MongoDB

一 下载镜像
[root@localhost mongodb]# docker pull mongo
Using default tag: latest
latest: Pulling from library/mongo
d13d02fa248d: Pull complete
bc8e2652ce92: Pull complete
3cc856886986: Pull complete
c319e9ec4517: Pull complete
b4cbf8808f94: Pull complete
cb98a53e6676: Pull complete
f0485050cd8a: Pull complete
ac36cdc414b3: Pull complete
61814e3c487b: Pull complete
523a9f1da6b9: Pull complete
3b4beaef77a2: Pull complete
Digest: sha256:d13c897516e497e898c229e2467f4953314b63e48d4990d3215d876ef9d1fc7c
Status: Downloaded newer image for mongo:latest
二 使用容器
[root@localhost mongodb]# docker run --name mymogo -d mongo --auth
b0e1869ffd890cb06428c0897d4e5ce892c8e1780fd5f89b9e0b70f6c101876a
[root@localhost mongodb]# docker exec -it mymogo mongo admin
MongoDB shell version v3.4.10
connecting to: mongodb://127.0.0.1:27017/admin
MongoDB server version: 3.4.10
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
> db.createUser({ user: 'jsmith', pwd: 'some-initial-password', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });
"db" : "admin"
        }
    ]
}Successfully added user: {
    "user" : "jsmith",
    "roles" : [
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }
    ]
}
> Successfully added user: {
...     "user" : "jsmith",
...     "roles" : [
...         {
...             "role" : "userAdminAnyDatabase",
...             "db" : "admin"
...         }
...     ]
... }
2017-12-03T00:48:51.770+0000 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:13
三 参考
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值