-
docker pull mongo
-
docker run -d --restart=always --name mongo-db -v ~/mongo/data:/data/db -p 27017:27017 mongo
sudo lsof -i -P -n | grep 27017
- sudo nano /etc/mongodb.conf
- bind_ip = 127.0.0.1 => bind_ip = 0.0.0.0 or bind_IP = 127.0.0.1, SERVER
- sudo systemctl restart mongod.service
e.g. ssh -fN -l ubuntu -i ./ssh-key.pem -L 9999:localhost:27017 [remote public ip]
ssh with pem: 9999
is your local port mapped to remote port, localhost is remote 'localhost', remote public ip
is remote public IP
If mongo container is running on VM, once the VM OS is suspended, mongodb cannot be accessed and must restart VM OS !