Skip to content

Docker compose files to run a Docker-ized MongoDB instance to assist MongoDB Basics course

Notifications You must be signed in to change notification settings

techs-playground/mongodb-basics-docker-compose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This repo contains all the materials for the course MongoDB Basics, in order to run a MongoDb in a docker container, load the provided data, connect with created and provided atlas clusters and play with them.

Docker

The docker-compose materials is located at docker folder, they contain:

  • The docker-compose.yml file which runs the latest mongodb database
  • The loadMovieDetailsDataset.js to be loaded into the atlas cluster created at https://cloud.mongodb.com

Running the container

To run the container go to the docker folder and then run the following command in a CLI:

$ docker-compose up

Or to run in detached mode (background):

$ docker-compose up -d

After successfully run the container, run the following command and copy the CONTAINER ID:

$ docker container ls

Connecting to the MongoDB Basics class Atlas clustes

Now run the following command to connect to the MongoDB Basics class Atlas cluster:

$ docker exec -it [REPLACE_WITH_CONTAINER_ID] mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluste
r0-shard-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

Connecting to my class Atlas clustes

Now run the following command to connect to my Atlas cluster:

$ docker exec -it [REPLACE_WITH_CONTAINER_ID] mongo "mongodb+srv://sandbox-4cvi6.mongodb.net/test" --username m001-student --password [REPLACE_WITH_PASSWORD]

To get the password go to the protected link https://thinfi.com/9isc and copy the password provided in the step 7.

Loading provided dataset to the my Atlas cluster

After connect to my Atlas cluster, run the following command from the mongo shell to load the movieDetails dataset:

MongoDB Enterprise Sandbox-shard-0:PRIMARY> load("loadMovieDetailsDataset.js")

Now confirm that the dataset has been loaded successfully running the following commnds in the mongo shell:

MongoDB Enterprise Sandbox-shard-0:PRIMARY> show dbs
MongoDB Enterprise Sandbox-shard-0:PRIMARY> use video
MongoDB Enterprise Sandbox-shard-0:PRIMARY> show collections
MongoDB Enterprise Sandbox-shard-0:PRIMARY> db.movieDetails.find().pretty()

When playing around with the delete CRUD operation, use the following command to load the reviews dataset:

$ docker exec -it [REPLACE_WITH_CONTAINER_ID] mongo "mongodb+srv://sandbox-4cvi6.mongodb.net/video" --username m001-student --password [REPLACE_WITH_PASSWORD] loadReviewsDataset.js

About

Docker compose files to run a Docker-ized MongoDB instance to assist MongoDB Basics course

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published