Giter Site home page Giter Site logo

Comments (5)

DmitryEfimenko avatar DmitryEfimenko commented on May 29, 2024 2

Failed to connect to 127.0.0.1:27017

You are getting this error because it takes a bit of time to start up mongo service. It seems people are using something like the following to avoid it:
Dockerfile:

FROM mongo:3.2.0
COPY setup.sh /setup.sh
RUN /setup.sh

setup.sh:

#!/bin/bash

mongod --dbpath /data/db &

RET=1
while [[ RET -ne 0 ]]; do
    echo "=> Waiting for confirmation of MongoDB service startup"
    sleep 5
    mongo admin --eval "help" >/dev/null 2>&1
    RET=$?
done

ADMINUSER=user
ADMINPASS=pass

echo "=> Creating an admin user in MongoDB"
mongo admin --eval "db.createUser({user: '$ADMINUSER', pwd: '$ADMINPASS', roles:[{role:'root',db:'admin'}]});"

mongod --dbpath /data/db --shutdown

However, after successfully building this image, and starting a container using this image with command --auth I can't seem to be able to connect to the database using user I created above. Anybody has idea why?

@tianon , your input would be very appreciated!

from mongo.

codingwithoutcomments avatar codingwithoutcomments commented on May 29, 2024 1

I agree would great to have a variable i could set to enable auth.

from mongo.

xgdgsc avatar xgdgsc commented on May 29, 2024

I also think it would be great to have a variable I could set to enable auth.

from mongo.

yosifkit avatar yosifkit commented on May 29, 2024

@xgdgsc, like #145? (Still fixing bugs added by this, which is why it is not documented).

from mongo.

yosifkit avatar yosifkit commented on May 29, 2024

Closing old issue, fixed by #145. Feel free to comment if you feel this was closed in error.

from mongo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.