Docker-compose mongoose Docker-compose mongoose docker docker

Docker-compose mongoose


In server.js use mongodb instead of localhost:

mongoose.connect('mongodb://mongodb:27018');

Because containers in the same network can communicate using their service name.

Bear in mind that each container and your host have their own localhost. Each localhost is a different host: container A, container B, your host (each one has its own network interface).


Edit:

Be sure to get your mongo up:

docker-compose logs mongodbdocker-compose ps

Sometimes it doesn't get up because of disk space.


Edit 2:

With newer versions of mongo, you need to specify to listen to all interfaces too:

command: mongod --port 27018 --bind_ip_all


I think, that you should add links option in your config. Like this:

ports:  - "6820:6820"depends_on:  - mongodblinks:  - mongodb

update

As I promised

version: '2.1'services:    pm2:      image: keymetrics/pm2-docker-alpine:6      restart: always      container_name: pm2      volumes:        - ./pm2:/app      links:        - redis_db        - db      environment:        REDIS_CONNECTION_STRING: redis://redis_db:6379    nginx:      image: firesh/nginx-lua      restart: always      volumes:        - ./nginx:/etc/nginx        - /var/run/docker.sock:/tmp/docker.sock:ro      ports:        - 80:80      links:        - pm2        s3: # mock for development      image: lphoward/fake-s3:latest    redis_db:      container_name: redis_db      image: redis      ports:        - 6379:6379    db: # for scorebig-syncer      image: mysql:5.7      ports:        - 3306:3306