On my distant server, I use a docker container started with:
MONBULDING_PORT="8080" docker-compose up -d --no-deps --build monbulding-mongo
It works pretty well if I don't set any username/password to authenticate. Here is the corresponding docker-compose.yaml
file:
monbulding-mongo:
image: mongo:latest
ports:
- "27017:27017"
Now, if I want to set a username/password to access to MongoDB, I change this file into:
monbulding-mongo:
image: mongo:latest
ports:
- "27017:27017"
environment:
- AUTH=yes
- MONGODB_ADMIN_USER=admin
- MONGODB_ADMIN_PASS=password
- MONGODB_APPLICATION_DATABASE=app
- MONGODB_APPLICATION_USER=user
- MONGODB_APPLICATION_PASS=password
And if I try to log in to MongoDB using Robo 3T
, it doesn't work:
Someone know what I do wrong ? Thanks!
EDIT : I also tried with mongo shell
:
mongo --host domain.net -u admin -p password
But there is an error too.
If you are using this: https://github.com/aashreys/docker-mongo-auth it creates a file /data/db/.mongodb_password_set
after creating the user, so next time it skips the user creation. If you need to force it to create another user make sure to remove that file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.