docker search mongo
docker pull mongo:4.2.0
docker run --name mongo -p 27017:27017 -v /mnt/mongodb/data:/data/db -v /mnt/mongodb/backup:/data/backup -d mongo:4.2.0
登录:
docker exec -it mongo mongo admin
db.createUser({ user:'root',pwd:'123',roles:[ { role:'userAdminAnyDatabase', db: 'admin'}]});
远程访问,mongodb 的容器当中操作修改bindIP
docker exec -it mongo bash
apt-get update
apt-get install nano
nano /etc/mongod.conf.orig
# 修改bindIP为0.0.0.0
bindIp: 0.0.0.0
使用客户端连接:
?
?如果勾选上ssl连接会报错
Error receiving request from client: SSLHandshakeFailed: SSL handshake received but server is started without SSL support. Ending connection from 192.168.31.108:63786 (connection id: 18),
?
?
|