Coder Social home page Coder Social logo

docker-mongodb-replica-set's Introduction

MongoDB ReplicaSet Dockerfile

A Dockerfile and config for launching a MongoDB contatiner with 3 mongo processes that act as a ReplicaSet. There are config files for each mongo instance that are copied to the container. The shell script handles creation of the data directories and starting mongo.

Notes

It's probably not a good idea to run this setup in production as each mongo instance should be split across different machines. However for a local development environment this fits our needs.

Base Docker Image

Installation

  1. Install Docker.
  2. docker build -t="inlight/mongodb-replica-set" github.com/inlight-media/docker-mongodb-replica-set

Usage

Refer to Dockerfile MongoDB for usage notes not specific to ReplicaSet

Create container from image and open ports for ReplicaSet

docker run -itd -p 27017:27017 -p 27018:27018 -p 27019:27019 --name mongodb inlight/mongodb-replica-set

Initiate ReplicaSet

Once the container is running you can initialize the ReplicaSet with the following steps:

  • Access shell of container with docker exec -it mongodb bash
  • Access mongo shell with mongo
  • rs.initiate() to initiate ReplicaSet
  • Use the output of previous step to grab the 'me' (hostname of the machine) property to add to ReplicaSet:
    • port 27018: rs.add('9488f884u84:27018')
    • port 27019: rs.add('9488f884u84:27019')
  • You can use rs.status() to see if your ReplicaSet has started successfully

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.