Closed dbclkclk closed 7 years ago
Hi, thank you for reporting this issue. I am working on it.
@dbclkclk
docker-compose pull
or docker pull khezen/mongo
to download the new version
version: '2'
services:
database:
build: ..
ports:
- "27017:27017"
environment:
DB_USER: root
DB_PWD: p@ssw0rd
DB_NAME: blah
AUTH: y
restart: always
Db 'blah' is not shown in the dbs list until the first document is inserted but the db is created:
use admin
switched to db admin
db.auth("admin", "changeme")
1
show dbs
admin 0.000GB
local 0.000GB
if you connect to your mongod instance with the mongo shell you should see expected users by typing:
use admin
switched to db admin
db.auth("admin", "changeme")
1
db.system.users.find().pretty()
{
"_id" : "admin.admin",
"user" : "admin",
"db" : "admin",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "hMgNs3M7s8Uy4u5/jxxYLw==",
"storedKey" : "l5VrDRoNl8/WA7UyUScjck7YTcY=",
"serverKey" : "WmjbpR+jZpQ89X/tt7QRigJzf58="
}
},
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
{
"_id" : "blah.root",
"user" : "root",
"db" : "blah",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "cvmsEiidBsNyd4JXnaev7Q==",
"storedKey" : "LbFXQKoLh7VH8KUeazFC7xVPx48=",
"serverKey" : "7kvhviPbSc1rHoksZlsh8i5rtuQ="
}
},
"roles" : [
{
"role" : "dbOwner",
"db" : "blah"
}
]
}
I am not a compass user. As a shell user, I am able to connect to the mongod instance without any auth. However, I am not allowed to perform any operation on 'blah' until authentication is done:
use blah
switched to db blah
db.test.insert({"test": "I am authenticated"})
WriteResult({
"writeError" : {
"code" : 13,
"errmsg" : "not authorized on blah to execute command { insert: \"test\", documents: [ { _id: ObjectId('58579f705727d13b2b66dfe2') } ], ordered: true }"
}
})
db.test.find().pretty()
Error: error: {
"ok" : 0,
"errmsg" : "not authorized on blah to execute command { find: \"test\", filter: {} }",
"code" : 13,
"codeName" : "Unauthorized"
}
use blah
switched to db blah
db.auth("root", "p@ssw0rd")
1
db.test.insert({"test": "I am authenticated"})
WriteResult({ "nInserted" : 1 })
db.test.find().pretty()
{
"_id" : ObjectId("5857a16585535764ba337c6c"),
"test" : "I am authenticated"
}
Please tell me if you have any issue with this new version
Hi:
Awesome container however, I am having an issue. Whenever I set the
It doesn't create the DB nor does it set authentication to true. I am able to connect to the running monodb in my container using Compass without credentials; when I try with credentials, it says invalid user for
root: p@ssw0rd
. Kindly let me know what could be the issue.This is my docker-compose.yml
Thanks.