Comments (5)
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.
I agree would great to have a variable i could set to enable auth.
from mongo.
I also think it would be great to have a variable I could set to enable auth.
from mongo.
@xgdgsc, like #145? (Still fixing bugs added by this, which is why it is not documented).
from mongo.
Closing old issue, fixed by #145. Feel free to comment if you feel this was closed in error.
from mongo.
Related Issues (20)
- MONGO_INITDB_DATABASE not working HOT 5
- Failed to start Docker - storage.journal.enabled HOT 2
- Cannot create sharded cluster from version 5.0 HOT 2
- is the documentation broken? HOT 12
- MONGO_INITDB_ROOT_USERNAME / PASSWORD does not work on windows images
- Enhanced Query Builder for MongoDB Node.js Driver HOT 1
- Cannot run mongodb/mongodb-community-server:latest on Mac M2 HOT 1
- Incorrect initial password because of invalid behaviour of _js_escape HOT 2
- Considering updating the documentation to state that the default configuration of this container is insecure HOT 6
- PGP KEYS expired for Mongodb v3.6 HOT 2
- CVE-2023-29403 HOT 3
- Add an example to documentation for "Initializing a fresh instance" HOT 1
- docker run mongo failed
- Mongo 6.0+ Fails to Run Using WSL HOT 6
- Is it possible Docker without WSL?
- Need help with CVE-2023-24538, CVE-2023-24540, CVE-2024-21626 and CVE-2023-27561 HOT 4
- Not connecting in the mongodb compass - getaddrinfo ENOTFOUND db-mongo-node17 HOT 6
- Mongo container sends network requests to mysterious EC2 servers at AWS HOT 9
- MongoDB container not always initialising after clearing volumes HOT 1
- 7.0.7 tag is missing linux/arm64 image HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongo.