MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Impossibile connettersi a MongoDB tramite node.js in Docker

Prova:

mongodb.MongoClient.connect('mongodb://mongo:27017', ... );

Modifica il tuo docker-compose.yml :

version: "2"

services:

  web:
    build: .
    volumes:
      - ./:/app
    ports:
      - "3000:3000"
    links:
      - mongo

  mongo:
    image: mongo
    ports:
      - "27017:27017"

E usa alcuni comandi di composizione della finestra mobile:

docker-compose down
docker-compose build
docker-compose up -d mongo
docker-compose up web