SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

Cannot connect to mongodb shell (docker-compose setup method) #288

Closed ghost closed 6 years ago

ghost commented 6 years ago

Environment information:

OS: Linux Mint 18.3 cinnamon 64bit Docker version: 1.13.1 mongoDb version: v3.6.5 restheart version: 3.4.0-SNAPSHOT

Context / Steps to reproduce

I followed the setup guide in particular: Quick start with docker compose Installed docker $ sudo apt install docker $ mkdir restheart $ cd restheart Downloaded docker compose configuration $ curl https://raw.githubusercontent.com/SoftInstigate/restheart/master/docker-compose.yml --output docker-compose.yml

started the api $ sudo docker-compose up -d

tested the basics of the api as in the tutorial, then shut it down $ sudo docker-compose down

then i tried to follow the User provisioning tutorial to enable the database identity manager, so i had to find the "etc" folder: # cd /var/lib/docker # find -name restheart.yml with this output: ./aufs/diff/[a-long-id]/opt/restheart/etc/restheart.yml

now i edited both security.yml and restheart.yml as stated in the tutorial: restheart.yml idm: implementation-class: org.restheart.security.impl.DbIdentityManager conf-file: ./etc/security.yml access-manager: implementation-class: org.restheart.security.impl.SimpleAccessManager conf-file: ./etc/security.yml ...

security.yml `dbim:

saved and closed. started again the api with $ sudo docker-compose up -d without errors now i'm trying to:

Start the mongo shell and insert the administrative user by hand

(by the way there is a typo on this line in the tutorial)

installed mongo $ sudo apt install mongodb-clients

then i tried various possible connection strings: mongo --username restheart --password R3ste4rt! --authenticationDatabase admin (i found this as a comment in the docker-compose.yml file)

mongo 127.0.0.1:27017 --username restheart --password R3ste4rt! --authenticationDatabase admin

mongo 127.0.0.1:27017/auth --username restheart --password R3ste4rt! --authenticationDatabase admin

these resulting in:

MongoDB shell version: 2.6.10
connecting to: test (or auth)
2018-05-29T15:10:45.347+0200 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2018-05-29T15:10:45.348+0200 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146

mongo 192.168.99.100:27017 --username restheart --password R3ste4rt! --authenticationDatabase admin

mongo 192.168.99.100:27017/auth --username restheart --password R3ste4rt! --authenticationDatabase admin

these resulting in:

MongoDB shell version: 2.6.10 connecting to: 192.168.99.100:27017/test (or auth) 2018-05-29T14:50:18.368+0200 Error: couldn't connect to server 192.168.99.100:27017 (192.168.99.100), connection attempt failed at src/mongo/shell/mongo.js:148 from what (little) I can understand from the logs $ sudo docker logs restheart $ sudo docker logs restheart-mongo everything seems fine.

How can i connect to the mongo shell and insert the administrative user by hand?

here are the logs: docker-logs-restheart.txt docker-logs-restheart-mongo.txt

and the YML files: YML.zip

ujibang commented 6 years ago

Hi, this is more a question about docker but here we are!

First to edit the configuration files please follow the instruction on section Modify the configuration for the RESTHeart container

Second, to connect to mongod running in the docker container, you need to map port 27017. Just uncomment the following section in docker-compose.yml

Uncoment below if you want to map mongodb port

  #ports:
  #   - "27017:27017"
ghost commented 6 years ago

Solved, thanks!