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

Docker-compose automate creating replicaset for build pipelines #425

Closed
farzadz opened this issue Oct 19, 2020 · 1 comment
Closed

Docker-compose automate creating replicaset for build pipelines #425

farzadz opened this issue Oct 19, 2020 · 1 comment
Labels
question Usability question, not directly related to an error with the image

Comments

@farzadz
Copy link

farzadz commented Oct 19, 2020

I recently tried creating a standalone replica set for a build pipeline that uses multi-document transactions in tests. The issue is that the host is only available when the build is running and I cannot manually run rs.initiate() for cluster setup. From the docs and this issue I came up with this (there are more services in the compose file but I skipped them here):

version: '3'

services:

  mongodb:
    image: mongo:4
    ports:
      - 27017:27017
    volumes:
      - /etc/mongod.conf:/etc/mongod.conf
      - /etc/mongo-setup:/docker-entrypoint-initdb.d
    entrypoint: [ "mongod","-f","/etc/mongod.conf" ]
    restart: always

The contents of /etc/mongod.conf is as follows:

storage:
  dbPath: /data/db
  journal:
    enabled: true

net:
  port: 27017
  bindIp: 0.0.0.0


# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

#operationProfiling:

replication:
  replSetName: rp0

and /etc/mongo-setup contains a simple .sh file with this single line:

mongo --eval "rs.initiate()"

Later, I noticed because I changed the entrypoint in the compose file, docker-entrypoint.sh is not run and as a result, the shell file in docker-entrypoint-initdb.d is skipped. Any help regarding this is much appreciated.

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Oct 19, 2020
@wglambert
Copy link

https://github.com/docker-library/docs/tree/master/mongo#using-a-custom-mongodb-configuration-file
You should pass --config /etc/mongod.conf as a command rather than overwriting the entrypoint. The entrypoint will forward the command when it finishes

For further help you should try asking over at the Docker Community Forums, Docker Community Slack, or Stack Overflow. Since these repos aren't really a user-help forum
There was also this thread that has a lot of discussion around replica sets #246

@tianon tianon closed this as completed Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants