5

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:enter image description here

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.

Victor Castro
  • 1,232
  • 21
  • 40

1 Answers1

0

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

Ninten
  • 565
  • 3
  • 10