我试图在一个窗口容器上运行一个mongo实例。
我已经找到了关于身份验证的答案,但是我不为MongoDB: Server has startup warnings ''Access control is not enabled for the database''工作。
我有一个cfg文件,我用它来启动mongo,我的映像是基于一个现有的mongo停靠器映像,我只是在上面复制我的配置文件,并试图指示mongo使用它。实际上,我不知道它是否真的做到了这一点,但据我所知,基本图像CMD已经超过了我的新的CMD。
这是文件
FROM mongo:windowsservercore-1809
WORKDIR c:\
COPY .\mongod.Win.cfg .
CMD ["mongod", "--auth", "-f", "mongod.Win.cfg"]这是我的mongod.win.cfg
storage:
dbPath: C:\data\db
journal:
enabled: true
security:
authorization: enabled我要在一个码头构图中塑造形象
invoice_db:
build:
context: ./Invoice.Db
dockerfile: ./mongo.win.Dockerfile
image: mongo:v1
container_name: invoice-db
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: "admin"
MONGO_INITDB_ROOT_PASSWORD: "pass"
volumes:
- invoice-data-volume:c:\data\db
restart: unless-stopped
volumes:
invoice-data-volume:
name: invoice-data当我在容器中ssh并尝试以管理员身份登录密码传递时,我得到以下信息
PS C:\> mongo
MongoDB shell version v5.0.9
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("17467fb1-ecf9-426c-9041-0f15c3a47d30") }
MongoDB server version: 5.0.9
================
Warning: the "mongo" shell has been superseded by "mongosh",
which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
an upcoming release.
For installation instructions, see
https://docs.mongodb.com/mongodb-shell/install/
================
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
https://community.mongodb.com
> use admin
switched to db admin
> db.auth("admin", "pass")
Error: Authentication failed.
0
> db.auth("admin", passwordPrompt())
Enter password:
Error: Authentication failed.
0
>正在运行的容器中的日志。
{"t":{"$date":"2022-07-18T23:38:10.420+03:00"},"s":"I",“c”:“访问”,"id":20436,"ctx":"conn1",“msg”:“检查授权失败”,“attr”:{“错误”:{“代码”:13,“codeName”:“未授权管理员执行命令{ getCmdLineOpts: 1.0,”lsid:{ id: UUID("17467fb1-ecf9-426c-9041-0f15c3a47d30") },$db:"admin“}}
{"t":{"$date":"2022-07-18T23:38:18.120+03:00"},"s":"I",“c”:“访问”,"id":20436,"ctx":"conn1",“msg”:“检查授权失败”,“attr”:{“错误”:{“代码”:13,“codeName”:“未授权管理员执行命令{ listCollections: 1.0,filter:{},nameOnly: true,authorizedCollections: maxTimeMS: 1000.0,lsid:{ id: UUID("17467fb1-ecf9-426c-9041-0f15c3a47d30") },$db:"admin“}}
{"t":{"$date":"2022-07-18T23:38:21.712+03:00"},"s":"I",“c”:“访问”,"id":20251,"ctx":"conn1",“msg”:“为未知用户请求的支持conn1机制”,“attr”:{“user”:{“user”:{“admin”,“db”:“admin”}
{"t":{"$date":"2022-07-18T23:38:21.713+03:00"},"s":"I",“c”:“访问”,"id":20249,"ctx":"conn1",“msg”:“身份验证失败”,“attr”:“机制”:“SHA 1”,“猜测”:false,“principalName”:“principalName”,"authenticationDatabase":"admin",“远程”:“127.0.0.1:49160”、"extraInfo":{}、“错误”:“UserNotFound:未能找到db "admin”}的用户“admin”}
{"t":{"$date":"2022-07-18T23:38:25.438+03:00"},"s":"I",“c”:“访问”,"id":20436,"ctx":"conn1",“msg”:“检查授权失败”,“attr”:{“错误”:{“代码”:13,“codeName”:“未授权管理员执行命令{ listCollections: 1.0,filter:{},nameOnly: true,authorizedCollections: maxTimeMS: 1000.0,lsid:{ id: UUID("17467fb1-ecf9-426c-9041-0f15c3a47d30") },$db:"admin“}}
{"t":{"$date":"2022-07-18T23:38:32.311+03:00"},"s":"I",“c”:“访问”,"id":20251,"ctx":"conn1",“msg”:“为未知用户请求的支持conn1机制”,“attr”:{“user”:{“user”:{“admin”,“db”:“admin”}
{"t":{"$date":"2022-07-18T23:38:32.312+03:00"},"s":"I",“c”:“访问”,"id":20249,"ctx":"conn1",“msg”:“身份验证失败”,“attr”:“机制”:“SHA 1”,“猜测”:false,“principalName”:“principalName”,"authenticationDatabase":"admin",“远程”:“127.0.0.1:49160”、"extraInfo":{}、“错误”:“UserNotFound:未能找到db "admin”}的用户“admin”}
{"t":{"$date":"2022-07-18T23:38:37.028+03:00"},"s":"I",“c”:“存储”,"id":22430,“ctx”:“复选指针”,"msg":"WiredTiger消息“,”attr“:{”消息“:”1658176717:28384,WT_SESSION.checkpoint:保存检查点快照分钟: 34,快照最大值: 34,最老的时间戳:(0,0),元检查点时间戳:(0,0)基写gen: 1“}
{"t":{"$date":"2022-07-18T23:39:37.051+03:00"},"s":"I",“c”:“存储”,"id":22430,“ctx”:“复选指针”,"msg":"WiredTiger消息“,”attr“:{”消息“:”1658176777:50893,WT_SESSION.checkpoint:保存检查点快照分钟: 37,快照最大值: 37,快照计数: 0,最老的时间戳:(0,0),元检查点时间戳:(0,0)基写gen: 1“}
{"t":{"$date":"2022-07-18T23:40:37.067+03:00"},"s":"I",“c”:“存储”,"id":22430,“ctx”:“复选指针”,"msg":"WiredTiger消息“,”attr“:{”消息“:”1658176837:67089,WT_SESSION.checkpoint:保存检查点快照分钟: 39,快照最大值: 39,最古老的时间戳:(0,0),元检查点时间戳:(0,0)基写gen: 1“}
有人能帮我弄清楚吗?
发布于 2022-09-01 23:13:52
试着:
db.auth({user:"admin", pwd:"pass", mechanism:"SCRAM"})https://stackoverflow.com/questions/73028472
复制相似问题