Installing and deploying a MongoDB cluster in Docker

Source: Internet
Author: User
Tags mongodb server docker run

Installing MongoDB in Docker

MongoDB image in use: https://registry.hub.docker.com/u/tutum/mongodb/

Start a container with this image (note that MongoDB is standalone mode at this point):

Docker run-d--name=mongodb-p 27017:27017-p 28017:28017 tutum/mongodb:3.0

Docker logs MongoDB

Output information:

========================================================================

You can now connect to the this MongoDB server using:

MONGO admin-u admin-p 5elst6ktjrqv--host

Remember to change the above password as soon as possible!

========================================================================

MONGO Admin-u admin-p 5ELST6KTJRQV

# set a password for admin when running a container

Docker run-d--name=mongodb-p 27017:27017-p 28017:28017-e mongodb_pass= "Mypass" Tutum/mongodb

# Set empty password when running a container

Docker run-d--name=mongodb-p 27017:27017-p 28017:28017-e auth=no Tutum/mongodb

# login MongoDB and Change password

MONGO admin-u admin-p vjq6u0dshdn7--host

> Db.changeuserpassword ("USERNAME", "PASSWORD")


Deploying a MongoDB cluster in Docker

Start the MongoDB container (all nodes) in Replset mode:

Docker run-d--name mongodb-p 27017:27017-p 28017:28017 tutum/mongodb:3.0 mongod--replset "Rs0"

Log in to the container, connect to MongoDB, and create the cluster: (only on the primary node)

Docker exec-it Mongodb/bin/bash

Mongo

> Rs.initiate ()

> rs.add ("node002.example.com")
> rs.add ("node003.example.com")

> rs.status ()



This article is from the "fireworks easy to cool" blog, please be sure to keep this source http://yuanhuan.blog.51cto.com/3367116/1649386

Installing and deploying a MongoDB cluster in Docker

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.