Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connecting to Mongodb inside a docker with mongodb compass GUI

I have a mongodb database running on the default port 27017 in a docker container.

Is there a way to connect to the database with the mongodb compass GUI running natively on my ubuntu OS?

like image 221
samsung gather Avatar asked Mar 26 '18 14:03

samsung gather


People also ask

Can I use MongoDB in Docker?

Can MongoDB Run in a Docker Container? MongoDB can run in a container. The official image available on Docker Hub contains the community edition of MongoDB and is maintained by the Docker team. This image can be used in a development environment.

Why is MongoDB compass not connecting?

Ensure Your MongoDB Instance is Running Compass must connect to a running MongoDB instance. Make sure you have installed MongoDB and have a running mongod process. You should also check that the port where your MongoDB instance is running matches the port you provide in the Compass connect dialog.


Video Answer


1 Answers

docker run -p 27018:27017 and then connect from Compass on your host with port 27018. I don't see a reason to expose all ports.

like image 122
barakbd Avatar answered Sep 22 '22 00:09

barakbd