mongo remote connections open
Others
2020-03-17 17:09:11
views: null
Use docker deployment mongodb
-
-
-
-
docker run --name mongodb -v ~
/docker/mongo:/data/db -p 27017:27017 -d mongo
- Mirror Pull
- You can view mirror if the download was successful
-
-
docker images |
grep mongo
You should have the following display
-
-
mongo latest 7177e01e8c01 2 months ago 393MB
> 2 months ago, and depending on the mirroring 393MB pulling time and the size of the corresponding version.
- Use docker installation mongodb
- After executing the command, a mirror mount mongo the container begins to run is provided wherein * `--name` name *` -v` container path set mapping to map the local path into the container. Here , the path may customize * `-p` set port mapping, will be mapped to the local 27017 (right) 27 017 (right side) of the container
- Into the container.
-
-
docker
exec -it mongodb bash
The above command following meanings: used in the form of interaction, this implementation `bash` command` mongodb` name of vessel
- Use of `mongodb`
- Users create and establish a database
- Create a user * Enter the following command into the `mongo`
-
-
* Create user
-
-
-
-
-
-
-
-
-
roles: [ { role:
"userAdminAnyDatabase", db: "admin" } ]
-
-
-
-
-
-
-
roles: [{role:
"read", db: "demo"}]
-
Establishment of the database
-
-
- Mongo check whether the normal start
- A first write data
-
-
db.info.save({name: 'test', age: '22'})
Check written data
-
-
The results are as follows
-
-
{
"_id" : ObjectId("5c973b81de96d4661a1c1831"), "name" : "test", "age" : "22" }
> Where `_id` should be different and author
- Remote connections open
- Among container `mongodb`
-
-
-
-
-
-
# Mongo modify configuration files
-
vim /etc/mongod.conf.orig
Will be one of Bindip: 127.0.0.1
Comment out the `# bindIp: 127.0.0.1` or changed to` bindIp: 0.0.0.0` to open a remote connection
Origin www.cnblogs.com/kofsony/p/12511728.html