Connect to docker inside a server

Im sorry if this is a dumb question but I am kinda overwhelmed, I will try to be the clearest I can.

I have a cloud server, inside of it I host a web page and also store user generated data.
I access my server via SSH and once inside I execute docker exec -i <id> mongo and then use <database> to work inside my mongodb. I can do this no problem but I wanted to use Studio 3T to better visualize that data.

How can I replicate this in Studio 3t? Because I can access my server through ssh no problem, but this shows the Server’s database (admin, config, local)… and I dont want that, I want to access my databases INSIDE the server (the ones inside the docker containers). Maybe I’m getting something wrong. Do I have to put something different in the ports or server description? Or can I run the docker command once inside it in Studio 3T?

Thanks in advance

After much much searching and errors I found the answer myself. I could delete the question but if anyone needs the same info I can tell you what I found out.

The ssh connection worked using the same credentials as in winscp… now, to access the docker containers you need to go to the “Server” tile, use connection Standalone and in “Server” change “localhost” to you container’s IP. In “port” most probably you are going to have to leave the 27017 that’s standard for MongoDB. But you can check the port as you’re checking the IP.

To find the container IP:

  • Connect to the server via ssh as usual, and from there, run

docker ps

to list your containers (here you can check if the port is actually 27017 or other). From the list, gett the NAME from the one you want.

  • Run

docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ NAME

This returns the containers IP that you need for the “Server” field.

That was it, now my collections list include the ones from my container

1 Like

Thanks for sharing, it’s very helpful!