Table of Contents
Pull the latest mongo docker container:
sudo docker pull mongo
Looking for specific version then run
sudo docker pull mongo:4.0.5
Run the mongodb as docker container in daemon mode:
sudo docker run -d -p 27017:27107 -v ~/ng-backups/mongo-data:/data/db --name ngmongodb mongo
Login to container and test mongodb.
sudo docker exec -it czcmongodb bash
Then run,
mongo show dbs
and able to see the result something like this, then you have successfully installed it.
admin 0.000GB
config 0.000GB
local 0.000GB
Connecting AWS Docker running Mongodb instance from local machine / local mongodb compass
docker run -d -v /data/db:/data/db --name czcmongodb-uat --net=host mongo:3.4.4 --bind_ip 0.0.0.0 --port 27009
Note:
If you are running your mongodb docker container in AWS make sure to enable the 27009 port in both inbound and outbound rules of your EC2 running instance.
Not required to perform any EC2 restart, so just update the inbound and outbound rules and try to connect using this connection string from your mongodb compass from your local machine.
mongodb://your_elastic_ip_or_aws_ec2_instance_ip:27009