4
votes

I am using docker image https://hub.docker.com/_/mongo/ (Latest MongoDB version)

I run command

docker run --name some-mongo -d mongo

Then I install Studio 3T I enter connection information like this

enter image description here

but I can't connect. What is correct connection must declare in Studio 3T in this case? How to connect MongoDB instance (docker) by Studio 3T?

5

5 Answers

7
votes

You need to export the port you want to use in your docker command. e.g.

docker run -p 127.0.0.1:27017:27017 --name some-mongo -d mongo

This opens the port of the container on your host machine.

1
votes

If the answers below doesn't work for you, try this:

Found the solution in https://jquery.develop-bugs.com/article/10214076/How+to+connect+MongoDB+docker+by+Studio+3T%3F

I am using docker image https://hub.docker.com/_/mongo/ (Latest MongoDB version) I run command docker run --name some-mongo -d mongo Then I install Studio 3T I enter connection information like this but I can't connect. What is correct connection must declare in Studio 3T in this case? How to connect MongoDB instance (docker) by Studio 3T?

You need to export the port you want to use in your docker command. e.g.

docker run -p 127.0.0.1:27017:27017 --name some-mongo -d mongo

This opens the port of the container on your host machine.

You need to find the IP address where the Docker container is running. On Mac docker runs in the background inside a Linux VM that has its own IP. Thus localhost will not work. To find the IP, run docker-machine env default and set this IP in the Server field.

0
votes

You need to find the IP address where the Docker container is running. On Mac docker runs in the background inside a linux VM that has its own IP. Thus localhost will not work.

To find the IP, run docker-machine env default and set this IP in the Server field.

0
votes
  • Click New Connection

  • Enter the Connection name

  • Click on From URI

  • Enter the URI in the following format mongodb://{username}:{password}@{ip_address}:{port}/?authSource=admin

  • Click OK

  • Click Test Connection

  • Works?

    • No: Check your username, password, etc
    • yes: Congrats!
0
votes

for those on windows kindly check in task manager and make sure you don't have a local installation of mongo db server running then use localhost in address/connection string