How to Connect MongoDB container running inside the AWS EC2 instance from MongoDB Compass Application Locally

Locally Access your MongoDB Container that is running inside the AWS EC2 instance.

Photo by Christian Wiediger on Unsplash

Download the docker inside AWS EC2.

yum install -y docker

Download the docker image inside AWS EC2.

docker pull mongo:latest

Make a persistent folder for the Mongo DB server volume.

mkdir mongodb

While launching the mongo container mount the persistent volume and do patting (expose the container to the outer world).

docker run -d -p 27017:27017 -v ~/mongodb:/data/db — name mymongo
docker exec -it mymongo bash

Click to the Fill in connection fields individually.

We do not have the user and password so we can connect without it.

Mongo DB server allows 27017 port to connect externally.

Note: Make sure AWS Security Group does allow the 27017 port.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Neeraj Singh Negi
Neeraj Singh Negi

Written by Neeraj Singh Negi

AWS | Openstack | GCP | Ansible | Redhat 8 Linux | Docker | Jenkins | Kubernetes | Hadoop | Python | Machine Learning

No responses yet

Write a response