Giter VIP home page Giter VIP logo

ritesh-yadav / mongodb-docker Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 1.0 3 KB

There are instances when you want to create MongoDB instance in Docker to use in production or in local/internal. We came across this requirement where we were using MongoDB Atlas for production but wanted to use MongoDB docker in our local/internal/dev environment. Mongo Atlas uses SSL connection so we want to keep our local consistent with production environment. In this post, I am going to explain the process of creating Mongo Docker instance with valid SSL certificate and replicating same behaviour of MongoDB Atlas.

Home Page: https://ritesh-yadav.github.io/tech/docker-instance-of-mongodb-with-ssl-support/

Shell 100.00%
mongodb docker letsencrypt localhost ssl-support

mongodb-docker's Introduction

Docker For MongoDB

This project is to created docker image of MongoDB with a user. Read my post about this project

Pre-requisites

  1. Install docker in your machine from https://docs.docker.com/engine/installation/
  2. Run docker in your machine
  3. Make entry in your /etc/hosts file like 127.0.0.1 localhost ry-dev.herokuapp.com

Steps to Create Docker Container

  1. Go to folder which contains DockerFile
  2. Run docker build -t mongo . (mongo is the tag name which will be used in next step)
  3. Run docker run -d -p 27017:27017 --mount source=mongodb,target=/data/db --mount source=configdb,target=/data/configdb --name mongoDB mongo:latest (mongoDB is the container name which can be used for referring container in any other command)

Other Useful Commands

  • Check status of your container by docker ps -a
  • Check logs of the container by docker logs -f <CONTAINER ID OR NAME>
  • Remove any container docker rm <CONTAINER ID OR NAME>
  • Get shell in container docker exec -it <CONTAINER ID OR NAME> bash
  • Command line connection to MongoDB mongo --ssl --host ry-dev.herokuapp.com --port 27017 --username mongodb --password mymongopass --authenticationDatabase mydatabase

mongodb-docker's People

Contributors

ritesh-yadav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

demonarch

mongodb-docker's Issues

question

Do you have a docker-compose.yml example to run this? Thanks for considering...

Unable to login using the crednetials

I tried logging into the mongo service using the below crednetials,

  • admin/myadminpass
  • mongodb/mymongopass

None of them worked. But when I tried without username/password, I got into the shell, but I'm unable to perform any operation. When I try to execute any query such as show dbs, I'm getting the below error,

E QUERY [js] Error: there are no users authenticated :

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.