-
Notifications
You must be signed in to change notification settings - Fork 633
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
[Bug]: mongo requires alternate shell in command to work as shard config server #717
Comments
Is your |
Yes, for the sake of this discussion and my simplified example. And I know the Docker container is loading it because that's where it's getting the |
I am unable to reproduce this locally |
Is it possible you have some dangling volumes? Can you do a |
Big progress in tracking this down! It seems to be a problem only when setting Here's a complete services:
mongocfg1:
image: "mongo:8"
command: "mongod --config /etc/mongo/mongod.conf"
container_name: mongocfg1
# environment:
# - MONGO_INITDB_ROOT_USERNAME=root
# - MONGO_INITDB_ROOT_PASSWORD=pass123
# - MONGO_INITDB_DATABASE=default
restart: unless-stopped
healthcheck:
test:
- CMD
- echo
- ok
interval: 5s
timeout: 5s
retries: 10
start_period: 5s
mem_limit: "0"
memswap_limit: "0"
mem_swappiness: 60
mem_reservation: "0"
cpus: 0.0
cpu_shares: 1024
volumes:
- "mongodb-configdb:/users/me/Dropbox/dev-projects/mongodb/configdb"
- "mongodb-db:/users/me/Dropbox/dev-projects/mongodb/db"
- "/users/me/Dropbox/dev-projects/mongodb/mongo-mount:/tmp/root"
- type: bind
source: /users/me/Dropbox/dev-projects/mongodb/mongod.conf
target: /etc/mongo/mongod.conf
read_only: true
# - type: bind
# source: /users/me/Dropbox/dev-projects/mongodb/docker-entrypoint-initdb.d
# target: /docker-entrypoint-initdb.d
# read_only: true
volumes:
mongodb-configdb:
name: mongodb-configdb
external: false
mongodb-db:
name: mongodb-db
external: false Starting this as is will work fine. But start over after The same thing happens if commenting out the In this case, that last volume bind points to a JS file with these values: db = db.getSiblingDB("default")
db.createCollection("init_collection")
db.createUser({
user: "root",
pwd: "pass123",
roles: [{ role: "readWrite", db: "default" }],
}) So it seems this error is related to these init commands, but I'm not quite sure I understand why, yet. |
I can definitely rebase it for the newer releases, but I was never really sure that it was a great fix. We didn't really get feedback on it. Looking at this and #509, maybe 7-8 people have run into this problem in the past two years, so it hasn't been prioritized. |
I could see it becoming a higher priority as systems like Coolify are becoming more popular to fully manage a server using Docker containers. That's what I'm doing, and it's looking like I won't get to do so with my MongoDB shared setup because of this unresolved issue. |
Error Message and Logs
Steps to Reproduce
mongod.conf
:docker-compose.yml
file for starting mongo similar to this (simplified for illustration):docker compose up
.mongod.conf
.Additional Information
After a lot of digging and experimenting, I found the strangest cause for this. It's the
command
line ofdocker-compose.yml
. Whether I make itcommand: 'mongod --config /etc/mongo/mongod.conf'
orcommand: --config /etc/mongo/mongod.conf
, it will not read the replica set options when including theconfigsvr
option. And it doesn't seem to matter what I change inmongod.conf
.However, if we replace the
command
line with:Or:
And then run
docker compose up
,mongod
appears to start fine.Aside: even though the error message is complaining about missing replica set configuration, adding
--replSet NAME
to thecommand
line still didn't fix it. It seems the only way to use Docker to start a shard config server is by doing the shell trick as shown above.Although I've found this workaround, this is not the way the Docker image documentation says to do it, and it's not possible with systems that take control of
docker-compose.yml
(such as Coolify), forcing it back tocommand: 'mongod --config /etc/mongo/mongod.conf'
, which should work anyway!For reference, here's the MongoDB documentation on creating a shard config server. Yes, it points out binding an IP, but I've noticed that makes no difference with this problem.
The text was updated successfully, but these errors were encountered: