This commit is contained in:
vinchent 2024-09-01 07:39:42 +02:00
parent be71cc40d1
commit e047b35f77
2 changed files with 4 additions and 5 deletions

View File

@ -79,7 +79,7 @@ func connectToMongo() (*mongo.Client, error) {
} }
var result bson.M var result bson.M
if err = client.Database("Test").RunCommand(context.TODO(), bson.D{{Key: "ping", Value: 1}}).Decode(&result); err != nil { if err = client.Database("admin").RunCommand(context.TODO(), bson.D{{Key: "ping", Value: 1}}).Decode(&result); err != nil {
log.Println("Error ping:", err) log.Println("Error ping:", err)
return nil, err return nil, err
} }

View File

@ -51,9 +51,8 @@ services:
ports: ports:
- "27017:27017" - "27017:27017"
environment: environment:
MONGO_INITDB_DATABASE: logs MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_USERNAME: admin MONGO_INITDB_ROOT_PASSWORD: password
MONGO_INITDB_PASSWORD: password
volumes: volumes:
- ./db-data/mongo:/data/db - ./db-data/mongo:/data/db
@ -71,5 +70,5 @@ services:
environment: environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: admin ME_CONFIG_MONGODB_ADMINUSERNAME: admin
ME_CONFIG_MONGODB_ADMINPASSWORD: password ME_CONFIG_MONGODB_ADMINPASSWORD: password
ME_CONFIG_MONGODB_URL: mongodb://mongo:27017/ ME_CONFIG_MONGODB_URL: mongodb://admin:password@mongo:27017/
ME_CONFIG_BASICAUTH: false ME_CONFIG_BASICAUTH: false