Giter VIP home page Giter VIP logo

docker-compose-mongodb's Introduction

docker-compose-mongodb

MongoDB with Docker and Docker Compose

Usage (start server)

On folder that contains docker-compose.yml type one of this.

// non detach mode
docker-compose up

or

// detach mode
docker-compose up -d

It will spin the MongoDB latest version (currently 4.x.x version), expose port to host at 27017.

Usage (stop server)

To shutdown database without remove the container.

docker-compose stop

To shutdown database and remove the container.

docker-compose down

Is data or user that already created will gone? No, since in the Docker Compose file you can see that we utilize data container named mongodb_data_container to store the MongoDB data.

MongoDB credential (for database admin)

  • Username: root
  • Password: rootpassword

How to connect to MongoDB

Via mongo Shell

Type this.

mongo admin -u root -p rootpassword

It will connect to localhost port 27017.

Note that mongo command should be installed on the computer. On Linux this should be install mongodb-org-shell only. Refer to this for more detail https://docs.mongodb.com/manual/installation/

Some quick tips after logged-in

Show databases:

show dbs

Create new non-existant database:

use mydatabase

Show collections:

show collections

Show contents of a collection:

db.your_collection_name.find()

Save a data to a collection:

db.your_collection_name.save({"name":"Sony AK"})

Show database version:

db.version()

Enjoy your local MongoDB database server for any purpose you want, for me this setup is fine for testing purpose.

docker-compose-mongodb's People

Contributors

sonyarianto avatar

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.