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.
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.