[英]can't login to mongoDB in a docker-compose container with login/pass
On my distant server, I use a docker container started with: 在我的远程服务器上,我使用一个开头的docker容器:
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: 这是相应
docker-compose.yaml
文件:
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: 现在,如果我想设置用户名/密码来访问MongoDB,我将此文件更改为:
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: 如果我尝试使用
Robo 3T
登录MongoDB,它不起作用:
Someone know what I do wrong ? 有人知道我做错了什么吗? Thanks!
谢谢!
EDIT : I also tried with mongo shell
: 编辑:我也尝试过
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. 如果你使用它: https : //github.com/aashreys/docker-mongo-auth它在创建用户后创建一个文件
/data/db/.mongodb_password_set
,所以下次它会跳过用户创建。 If you need to force it to create another user make sure to remove that file 如果您需要强制它创建另一个用户,请确保删除该文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.