Q:

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? 

A:

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.

A:

Yes we can run
Steps:

Pull/Restart the docker container mongodb
Enter the bash shell
docker exec -it mongodb bash

Now open the mongodb compass community and with same default connection just click connect and the docker container's mongodb will be connected to compass community.

My terminal running docker:

Mongodb Compass:

