1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-11-30 09:16:41 +02:00
dockerfiles/mongo
2018-06-06 17:49:07 +08:00
..
docker-compose.yml update rocketchat 2018-06-06 17:49:07 +08:00
README.md upgrade shadowsocks-libev to 2.4.5 2016-02-03 00:10:22 +08:00

mongo

MongoDB is an open-source, document database designed for ease of development and scaling.

docker-compose.yml

mongo:
  image: mongo
  command: --auth
  container_name: mongo
  ports:
    - "27017:27017"
  restart: always

up and running

$ pwgen -1 8 2
pah4Xa0o
Aedahwa7

$ cd ~/fig/mongo/

$ docker-compose up -d

$ docker exec -it mongo bash
/# mongo
> use admin
> db.createUser({user: 'root', pwd: 'pah4Xa0o', roles: [{role: 'userAdminAnyDatabase', db: 'admin'}]})
> db.auth('root', 'pah4Xa0o')
> db.runCommand({usersInfo: 1})
> exit
/# exit

$ docker cp mongo:/usr/bin/mongo /usr/local/bin/

$ mongo mongodb://root:pah4Xa0o@localhost:27017/admin
> use mydb
> db.createUser({user: 'myuser', pwd: 'Aedahwa7', roles: [{role: 'readWrite', db: 'mydb'}]})
> exit

$ mongo mongodb://myuser:Aedahwa7@localhost:27017/mydb
> show collections
> exit

Read this and this for more help.