Mongodb compass connect to docker container Learn how to connect to a MongoDB instance running in a Docker container using MongoDB Compass, a powerful GUI for MongoDB. Learn how to connect the Compass GUI. On the bridge network you use the unmapped port number: 27017. 0:27017/demo mongodb://root: password@192. My docker-compose. Create a docker-compose. Mar 5, 2023 路 I’m running a node v18 express application on docker and I’m trying to connect to mongodb that is running on my host machine and not in the docker container. Sep 24, 2022 路 mongodb://hazem:123@localhost:27017/DB Your connection string is correct if it runs in a container, but then you need to make sure the container is on the same docker network as the database container. Mar 7, 2025 路 Learn how to set up MongoDB on Docker with this step-by-step guide. 馃搶This videos shows , how to run Mongo Db inside docker container and how to add the connection to Mongo Compas . Probably I’m missing something obvious, could anyone give a hint Jun 21, 2021 路 However all the steps in running containers in docker and connecting via compass remained the same as before. Create a Dec 10, 2020 路 It didn’t automatically restart, by the way. I have Public IP address to my VM, the port 27017 is open in my vm and also in my mongo container. However, I cannot seem to connect to the container from compass on my local machine. Is there a way to connect to the database with the mongodb compass GUI running natively on my ubuntu OS? Feb 7, 2023 路 MongoDB is a widely used NoSQL database that can function in containers if you know how to set it up. yml file in an empty directory. I have more than one mongo container running at the same time and they can’t all be at port 27027. I tried several connection strings but I am getting error no matter what I am using: Given this how can I connect to the Mongo instance in Docker? everything works pretty well and when i want to connect to my mongodb using mongodb compass it gives me authentication failed error, everything works fine when i dont specify username and password is there anything im doing wrong? i still havent tested my nodejs app to connect to mongo db, im afraid that my app couldnt connect to it too Nov 6, 2023 路 Tools and Connectors Learn how to connect to MongoDB MongoDB Drivers Use drivers and libraries for MongoDB Resources Hub Developer Center Explore a wide range of developer resources Community Join a global community of developers Courses and Certification Learn for free from MongoDB Events and Webinars Find an event or webinar near you Solutions To automate a containerized deployment of Atlas, you'll need to wait for the container to be in a healthy state before you can connect to Atlas. mongo db container create by docker-compose. It took Jun 24, 2022 路 I also cannot connect to it using MongoDB Compass with the connection string mongodb://localhost:27011/my_db that works with Mongo Shell. Docker containers run in an isolated environment including separate virtual networks by default. By following these steps, you can set up a local MongoDB instance using Docker on Windows 11 and connect to it using MongoDB Compass. by using docker-compose, there may be situations where you want to use a local MongoDB instance and connect to Mar 23, 2022 路 I am running an empty mongodb instance in a docker desktop container using: docker run --name mongodb -d -p 64000:64000 mongo Am running Compass v1. I have a mongodb database running on the default port 27017 in a docker container. 1 and attempting to connect to the mongodb running on localhost using the connection string: `mongodb://localhost:64000` In the Compass UI, I receive the following visible error: `connection to 127. See docker connect a service to the overlay network. My file looks: Jun 24, 2022 路 I also cannot connect to it using MongoDB Compass with the connection string mongodb://localhost:27011/my_db that works with Mongo Shell. The output shows that the MongoDB server is started correctly. js Frameworks mongodb-shell, containers, node-js, mongoose-odm Feb 1, 2023 路 I finally figured it out. (or the host might be slow to boot up mongodb container). Nov 11, 2024 路 To confirm that your MongoDB container is running, use the following command: docker ps This command lists all running containers. The following example demonstrates deploying an Atlas image in Docker and polling Docker to check the state of the container. My Node. May 5, 2023 路 Hi Team, Container is up and running, it show dbs for the command “docker exec -it mongosh”, but unable to connect from MongoDB Compass. Jan 14, 2022 路 A quick guide demonstrating how to connect to a local MongoDB instance from a Docker container. Also you will want a MongoDB ReplicaSet or Mar 21, 2024 路 The container running with Podman Desktop Accessing MongoDB with the CLI in the container To check that all is ok, you can open a shell on the container and connect to the MongoDB instance with Jan 20, 2021 路 Running MongoDB inside a Docker container with macOS and access it using Mongo Compass, for newbies Hi hi hi, welcome. I would like to recreate a single-node cluster with replicaSet locally with docker compose, also adding mongo-express to more easily access data I can connect to mongoDB via mongo-express and compass until I activate replicationSet. Apr 15, 2025 路 I am facing an issue while trying to connect to a MongoDB replica set (mongodb-1 and mongodb-2 containers) using MongoDB Compass. However, the I am getting different errors during the process and not able to connect to the replica set at all. PC Version: How to Install Docker on PC Linux Version: How to Install Docker on Linux MongoDB Compass: MongoDB Compass is a powerful GUI for querying, aggregating, and analyzing your MongoDB data in a visual environment. Jul 26, 2023 路 Post says the container is likely not running, however that’s not my case. Running MongoDB in a Docker Container For development, it is better to connect to an instance of MongoDB running inside a Docker container locally (instead of a cloud-hosted instance) to save resources. Look for the container named mymongodb to verify that it's active. Mar 23, 2022 路 I am running an empty mongodb instance in a docker desktop container using: docker run --name mongodb -d -p 64000:64000 mongo Am running Compass v1. 1:64000 closed` I have looked at the Compass log file and can see these entries: ``` a007 Connecting to mongoDB inside Docker using Compass Swift Next Step 456 subscribers Subscribed Sep 14, 2014 路 26 If you specified the correct port and still not able to connect to mongodb running in docker (like me), make sure you are using the service name (or container name) in your connection URL, e. MongoDB Compass has many features more and its easier to work with in development. Mar 15, 2024 路 This a very quick walkthrough of spinning up a mongodb server inside a docker container and connecting with it through the mongodb compass gui. Are there 2 different active instances of MongoDB at the same port 27017 and I'm only able to see the one outside the container even tho I mapped my ports? Aug 23, 2023 路 Hi, For my demo C# project I am trying to create a replica set through docker compose and connect to it first from NoSQLBooster/ Mongodb Compass and then from my C# application. When MongoDB container moves to another node, it should be able to read the existing data, or else, data will get lost. Contribute to DrSnowbird/mongo-compass-docker development by creating an account on GitHub. I created 3 docker containers for each MongoDB instance I want in my replica set mongodb_01: i. links:more Oct 14, 2024 路 HI, I am following the documentation at Deploying A MongoDB Cluster With Docker | MongoDB in a mac system running nerdctl as command line client to connect to containerd runtime. 23. I failed to use Atlas because my company blocked 27017 port for security reasons. 1:64000 closed I have looked at the Feb 8, 2023 路 MongoDB is a widely used NoSQL database that can function well in containers if you know how to set it up. Why would you wanna do this? Welcome to our comprehensive guide on setting up MongoDB within Docker, complete with connecting Docker to MongoDB Compass and saving data seamlessly. yaml mount a diretory from host mechine to the container for save the mongo datbases. Dec 12, 2023 路 I am trying to create local setup of mongo with 3 repilca nodes I have create docker compose file which contains 3 mongo nodes. When I run the project on windows 10, I can perfectly connect to my db via Mongo Compass using the standard connection string: I'm new to docker. Redis and memcached also running on host machine and not on the container. yml file using the connection string like mongodb://mongo:27017. Any solution Team… i have the same issue, after google two hours finally sovled; solution锛歠ind out the host machine direcory mounted into mongodb container, delete it,then re-create the mongodb container. Nov 30, 2022 路 A quick and a practical introduction to running MongoDB as a Docker container. But when I try to set the read preference as secondary, it just times out. The replica set is set up and running in Docker, but when I attempt to connect using Compa… Feb 8, 2023 路 MongoDB is a widely used NoSQL database that can function well in containers if you know how to set it up. Then the app container could talk with MongoDB. js app running on my Mac can connect to it without issues, only Compass is struggling. 1:27017 Feb 7, 2023 路 MongoDB is a widely used NoSQL database that can function well in containers if you know how to set it up. This article tells you how to create a MongoDB docker container with … Feb 22, 2022 路 However, using Docker Desktop is recommended for a seamless experience. Jan 8, 2024 路 Before attempting to connect, ensure MongoDB is actively running on your Windows machine. 3 (as I did in this post) should make it even easier, yet I cannot have services 2 (and 3) connect to MongoDB. I am able to connect to Mongo Express http://localhost:8086/ but when I open MongoDB Compass I am unable to connect. docker. 1:27017/demo run docker ps command in window it returns Jan 11, 2023 路 You see, “depends_on” is mainly to check if the container is booted but you need to also wait for the mongodb to fully start up listening on the port. hello () is what the client will try and connect to. Nov 16, 2021 路 The other day I struggled a bit in setting up MongoDb in a docker container and then connecting it with Compass – the MongoDb client. NET Core 2. Resolve common connection issues wit Jan 31, 2025 路 When working with MongoDB and Docker, I encountered an issue where the connection to MongoDB failed with an Authentication Failed error, even though the username and password were correct. After spending a lot of times searching through internet and trying various options, I finally decided to Feb 22, 2021 路 In this article, I’ll show you my Docker setup for container configurations and scripts to run a project’s MongoDB server in a Docker container. 3 database server done. For example, in the connection string: mongodb://mongo-mydb-user:pass Jul 31, 2024 路 I’m on windows 11. com) The main issue which I have wasted several days on: Here is the docker-compose file: networks: app As you might have noticed, you can connect to mongo service running on mongo container from other containers located in the same docker-compose. I have my mongodb on Ubuntu using wsl. How to use MongoDB Compass to connect to a MongoDB standalone, replica set, or sharded cluster host. Jan 19, 2018 路 You could create both containers on the same overlay network. g. I was able to connect to redis and memcached in similar way using host. May 4, 2024 路 I try to connect Docker to Mongodb compass, when I run “docker run --name mdb -d -p 27017:27017 mongo” and run my nodejs app, it doesn’t create the new database in MongoDbCompass although there no error connect. but when i am unable to connect to mongo with compass, its throwing Apr 28, 2023 路 Hi everyone, I am new to docker so this could be a noob issue. In case you want to connect from the host, you can use mongodb://localhost:27017 if you have exposed mongo port as shown above. 1, but I can no longer connect to my MongoDB server running on a different computer as Docker container on the local network. com:27017/?directConnection=true I run into a connection refused error. I'm trying to create a MongoDB container and a NodeJS container. Nov 27, 2024 路 Thank you for you help, but I know how to get the port dynamically exposed by docker. Jan 7, 2023 路 MongoDB with MongoDB Express. Feb 8, 2023 路 MongoDB is a widely used NoSQL database that can function well in containers if you know how to set it up. Nov 30, 2020 路 I’m running mongodb instance in docker: docker run --name mongodb -d -p 27017:27017 mongo When I try to connect to the instance from Compass v: 1. I started it manually, I can see I am now on version 1. Jul 17, 2024 路 This will start MongoDB in a container and map the local port 27017 to the container’s port 27017, making it accessible via mongodb://localhost:27017. Connect to MongoDB from another Docker container The MongoDB server in the image listens on the standard MongoDB port, 27017, so connecting via Docker networks will be the same as connecting to a remote mongod. Jul 26, 2024 路 Learn to run MongoDB in Docker, publish ports for Compass access, persist data across restarts, & connect via a Node Express server in this step-by-step guide. a MongoDB service; 2. As soon as I enter the mongo machine and run the rs. After clicking Connect, MongoDB Compass should successfully connect to your MongoDB instance running in the Docker container on your EC2 instance. 1) ip or localhost. I tried to connect with mongosh and succeeded. I am able to complete the setup properly and connect to the database from compass. I run the container using: docker run --name mongodb -v /data/db:/data/db -v /etc/mongo:/etc/mongo -p 27017:27017 -d mongo --config /etc/mongo/mongod. 1 web app accessing the MongoDB database. So you do not need to check for container IP every time. docker run -it --rm --network server_default mongo \ mongosh --host mongodb_container_gold_jar \ -u haolamongodb -p haolamongodb1210 --authenticationDatabase admin \ root so the connection string should be mongodb://haolamongodb: haolamongodb1210@127. Feb 18, 2023 路 How to a deploy a containerized version of MongoDB and connect to it from a machine or service outside of the hosting server. You can now explore your databases and collections through the GUI. As such, you could try using mongo6 as host name instead (or the reverse-proxy proxy, both should be possible with your setup). Another thing you need to consider is MongoDB data persistence. an ASP. Learn how to connect the Compass GUI here. Using this method, you will be able to connect to your MongoDB instance on mongodb://localhost:27017. sudo docker run -d -p 27017:27017 -v ~/data:/data/db mongo Jun 30, 2023 路 Instead of using the host as an "indirect route" to the container, you could utilize the network created by docker-compose (myNetwork) and use the service name (mongo6) to identify your container. Then I lookup the IP of the VM in which the container is running, like this: docker-machine ls Mar 31, 2025 路 However when I deploy it on a remote server and try to connect to it from a local Compass using a connect string like mongodb://my-remote-server-domain. Nov 3, 2022 路 I have the same issue that running replica set within local docker containers while failing to connect with my local Compass outside of the docker containers. Apr 4, 2023 路 0 You only use the hostname mongo_db when you connect to the container from another container on the Docker bridge network that docker-compose creates for you. Note that the data is created inside the container storage and will be destroyed when the containers are removed from the host system. rjohn@FIVE9-DYFPDQ0WXH ~ % lima nerdctl exec -it mongo1 Feb 8, 2023 路 MongoDB is a widely used NoSQL database that can function well in containers if you know how to set it up. 168. 1 and attempting to connect to the mongodb running on localhost us… Oct 31, 2024 路 With these steps, you now have MongoDB running inside a Docker container. See the list above for relevant tags. I suppose I can use network_mode: "host" in docker-compose config to alleviate the host discovery issue, but I would rather not do it. Summary: Learn how to connect to MongoDB running in a Docker container from both within the host machine and externally. 1 and attempting to connect to the mongodb running on localhost us… Oct 26, 2015 路 docker run -d --link mongo:mongo my_container Docker will then add an entry to /etc/hosts inside the container so that the name mongo resolves to the IP of the mongo container. Dec 1, 2021 路 I have tested access to the host and port using telnet and I can use mongo from the host where I’m running Compass to access the database running on another host in a container, however, Compass fails to connect and times out. js Microservices With RabbitMQ, MongoDB & Docker | Tutorial - YouTube mguay22/nestjs-rabbitmq-microservices (github. MongoDB compass is installed on Windows. So, how do I connect to those mongo databases using Compass? May 19, 2023 路 Really this comes down to the docker networking namespace and being able to resolve the hostnames. Feb 7, 2023 路 MongoDB is a widely used NoSQL database that can function well in containers if you know how to set it up. In this Oct 26, 2024 路 2. yml docker compose up test-db -d - to run a mongo db instance in background docker logs 427de4381436 - to verify if the instance is running Now when i try to access: mongo db via mongo-db compass with the below URLs: mongodb://localhost Jun 6, 2016 路 I'm running a Docker container on MacOS that starts a Postgres server and MongoDB server as follows: docker run -p 80:80 -p 27017:27017 dockertest * Starting PostgreSQL 9. Use the Mongodb-Compass to connect to Mongodb-docker The default password for local MongoDB: Mar 23, 2022 路 I am running an empty mongodb instance in a docker desktop container using: docker run --name mongodb -d -p 64000:64000 mongo Am running Compass v1. 0: mongodb://localhost:27017/admin Compass fail to connect with err… Jul 13, 2025 路 Learn how to quickly get up and running with MongoDB in a containerized environment with Docker for a consistent development experience. By following this tutorial, you have learned how to integrate MongoDB with Docker containers using Docker Compose, Dockerfiles, and Docker volumes. For me, I see it’s running and if I check the logs there are no traces of attempted connections from the microservices. Using either the Docker command or Docker Compose, you’ve set up persistent storage, secure access, and automatic restarts. Simplify your database management and deployment. mongodb://mongodb_service:27017/mydb, which is defined in your docker-compose. I can also connect to it using Compass (probably should’ve mentioned that). 8:27017/demo mongodb://root: password@172. Since Mongo provided a detailed procedure for deploy Mongo To spin up a local docker file what i am doing is: docker compose. You can also connect to your cluster using MongoDB Compass to create a database and add some documents. Feb 17, 2021 路 I'm working on a project that uses a mongo database running on docker. - in the same directory as per docker-compose. Apr 22, 2022 路 This article is for How to manage MongoDB with Docker container, to set up the MongoDB, to login into the container, and use of compass. Apr 8, 2020 路 I have the following docker compose file that I use to spin up a mongo docker container which works as intended. Containerizing your MongoDB database makes it portable across environments, letting you spin up an instance anywhere Docker is available. Aug 4, 2020 路 I have mongoDB container which runs on azure VM, and I'm trying to connect it to my mongoDB compass. Mar 6, 2019 路 In my remote machine, I've set up a docker container machine that I manage using docker-compose. 0. Here is my docker-compose file mongodb: container_name: ms_mongo_db image: Am running Compass v1. I recently spun up a MongoDB docker container and I am having troubles accessing it through Compass. It also relates to the replicaset discovery when a client connects, the hostnames and ports returned by db. depending on the data size in its data volume, this will take longer than you expected thus refusing any connection. yml : Feb 2, 2024 路 Updates these string not working- mongodb://root:password@mongo:27017/demo mongodb://demo:password@mongo:27017/demo mongodb://root:password@localhost:27017/demo mongodb://root: password@0. Mar 26, 2024 路 Outside the container I try to connect my MongoDB compass to 27017 or even use VSCode to connect to 27017, however the DB they connect to look different from the DB in my container. Once the container is in a healthy state, the script automates a connection to your Atlas instance with Mongosh. 24. But when I use Compass I can’t see the right databases (I’m connecting to localhost:27017. Any data created as part of the lifecycle of that container will be destroyed once the container is deleted. This is the first Aug 23, 2025 路 Learn how to integrate MongoDB with Docker through a detailed step-by-step guide designed for developers. This IP is going to change everytime you create mongo container. internal. Troubleshoot common connection errors in MongoDB Compass with solutions for issues like incorrect hostnames, firewall blocks, and authentication failures. yml exposes port correctly : ports: - "27017:27017" When I connect inside my containe Sep 12, 2019 路 If map the container port to host port like this, then you can directly connect with loopback (127. You can try it with Compass, MongoDB’s GUI to visualize and analyze your data. You can pull the latest MongoDB image and run it in a Docker container. * Starting database mongodb done. I started a docker container using the following docker-compose file below and after starting the docker container I’m able to use mongosh in the terminal and see my dbs in linux. I am new to MongoDB and docker so any help is really appreciated. May 3, 2022 路 After being able to start mongod server and mongo shell in WSL2, I wish to use MongoDB Compass installed on Windows to connect with the mongod server in WSL2. initiate(…) command then mongo Dec 2, 2020 路 I’m running mongodb instance in docker: docker run --name mongodb -d -p 27017:27017 mongo When I try to connect to the instance from Compass v: 1. Interestingly, when compass and docker were reinstalled it showed data from the old database. Prerequisites Docker: Docker installed on your system, we will use the official MongoDB image from Docker Hub. (Express is a Webbased admin ui) MongoDB with MongoDB Compass. This can be checked using MongoDB’s command-line tools or the services management interface in Windows Aug 24, 2023 路 0:00 introduction0:18 Downloading the mongo docker image1:23 Creating a container + port forwarding3:07 The Visual Studio Code MongoDB extension4:42 Creating Jul 22, 2024 路 I am trying to set up a MongoDB Docker container to use as a local database and use MongoDB Compass to connect. Although you can run your MongoDB in a container connected to such a virtual network, e. Oct 9, 2022 路 I created a MongoDB docker instance as follows: sudo docker run --name mongo -d -p 27000:27000 mongo I confirmed that the instance is running by using command sudo docker ps --all : CONTAINER ID Mongo Compass / GUI Docker application. Copy the following content into the newly Mar 6, 2023 路 Querying data in MongoDB using MongoDB Compass and Docker MongoDB main characteristics MongoDB is a document-style database: the document-style database uses the equivalent of an object as its … Jul 3, 2024 路 Hi, I am working on an application that needs a mongoDB with replicaSet. 1 and attempting to connect to the mongodb running on localhost using the connection string: mongodb://localhost:64000 In the Compass UI, I receive the following visible error: connection <monitor> to 127. Oct 2, 2023 路 AuthenticationFailed while trying to connect to mongo docker container Working with Data Node. a run-once service, used to seed the MongoDB with a database; 3. #containers #Docker #databases #MongoDB #tutorials Apr 4, 2021 路 In Docker Desktop I can see that the container is up and running. My connection string is missing the authenticationDatabase. When you connect from the host machine, you need to use localhost and the mapped port number. 0: mongodb://localhost:27017/admin Compass fail to connect with err… Nov 12, 2021 路 Docker is a platform that packages your application components as isolated containers. (Compass is a Desktop admin ui) Personally I prefer the later one. 30. You can do that with the Docker stop and rm commands. when you remove the container the mouted direcotry do not deleted, so the Jun 14, 2018 路 I’m trying to build this scenario with docker-compose: 1. That’s when I thought I would document the knowledg… Its shows connect to MongoDb Compass from docker and how to fix Mongodb compass Port issue COMMANDS USED:sudo docker run --name mongo_test -d mongodocker psM Mar 5, 2025 路 I have a MongoDB running in Docker, but I can't connect to it from MongoDB Compass. However I haven’t been able to do so. I’ve been trying to follow this tutorial and using an M1 Mac and bitnami MongoDB docker image: (2) Build Nest. Omitting nr. To request the other team to whitelist 27017 for Atlas usage is not a option in my situation. Perfect for developers and DevOps teams looking to containerize their databases. conf the mongod Feb 17, 2025 路 Conclusion Integrating MongoDB with Docker containers is a powerful way to scale and manage your database in a modern web development and DevOps environment. In this guide, we'll show you how to get started running MongoDB in Docker. nvgwnf otg layyi iygr wxj gnjaat owhxpu jlgbdg hyunc enhv gojbor ehorg svbd ukrcvl luz