Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB container environment variables not applied for authentication #715

Open
JustAnotherLars opened this issue Nov 6, 2024 · 1 comment

Comments

@JustAnotherLars
Copy link

I'm running a MongoDB instance as a Windows container using Docker Compose, and I'm having trouble with MongoDB authentication. Although I’ve set the MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD environment variables, MongoDB Compass fails authentication when I attempt to connect using these credentials. If I remove the username and password from the connection string in MongoDB Compass, I can connect without issues, which suggests the environment variables might not be applied correctly.

Docker Compose Configuration:

services:
  mongo:
    image: mongo
    restart: always
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example

Steps to Reproduce:

  1. Start the MongoDB container using the above Docker Compose configuration.
  2. Try connecting with MongoDB Compass using the following credentials.
    • Username: root
    • Password: example

Expected Behavior:
The MongoDB container should start with the specified root username and password, allowing authentication via MongoDB Compass.

Actual Behavior:
MongoDB Compass fails to authenticate with the provided credentials. However, I can connect without authentication if I omit the username and password from the connection string.

Question:
Why are the environment variables not being applied to the MongoDB container for authentication?

@tianon
Copy link
Member

tianon commented Nov 6, 2024

See #291 (comment) and #708 (we can't really implement the entrypoint for Windows containers effectively/correctly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants