Open
Description
Hi all,
OS: Windows 10 21H2 (OS Build 19044.1620)
VSCode: 1.65.2
MongoDB Extension: 0.9.2
Docker Desktop: 4.6.1 (76265)
I just had some issue connecting to a MongoDB server running inside Docker Desktop on Windows 10.
I kept getting the following error: Unable to connect: getaddrinfo ENOTFOUND mongo1
I was able to fix this by adding the following entry to my hosts
file: 127.0.0.1 mongo1
I don't have issues connecting to the DB via: mongoose, MongoDB Compass or NoSQLBooster for MongoDB
I also don't have issues connecting to clusters in Atlas
My local mongoDB is setup w/ this docker-compose.yaml
services:
mongo1:
hostname: mongo1
container_name: localmongo1
image: mongo:4.2.10
expose:
- 27017
ports:
- 27017:27017
restart: always
entrypoint: ["/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0", "--journal", "--dbpath", "/data/db", "--enableMajorityReadConcern", "false"]
volumes:
- ./storage/mongo/data1/db:/data/db
- ./storage/mongo/data1/configdb:/data/configdb
mongo2:
hostname: mongo2
container_name: localmongo2
image: mongo:4.2.10
expose:
- 27017
ports:
- 27018:27017
restart: always
entrypoint: ["/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0", "--journal", "--dbpath", "/data/db", "--enableMajorityReadConcern", "false"]
volumes:
- ./storage/mongo/data2/db:/data/db
- ./storage/mongo/data2/configdb:/data/configdb
mongo3:
hostname: mongo3
container_name: localmongo3
image: mongo:4.2.10
expose:
- 27017
ports:
- 27019:27017
restart: always
entrypoint: ["/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0", "--journal", "--dbpath", "/data/db", "--enableMajorityReadConcern", "false"]
volumes:
- ./storage/mongo/data3/db:/data/db
- ./storage/mongo/data3/configdb:/data/configdb
Any ideas why it was necessary to add this entry to my hosts file?