I run Node image based docker container (Docker quickstart terminal from Windows)
FROM node:7.8.0
ENV NPM_CONFIG_LOGLEVEL warn
VOLUME /tmp
#copy server sour
There are few things you can do here
Let other container run on network of other container
docker run --net container:<id> MyDockerImage
Now your mongodb will be accessible on localhost. But the port needs to be exposed in the container whose network is used
Create network yourself and use it
docker network create myapps
docker run --name mongodb_service --net myapps mongodb
docker run -p 3000-3009:3000-3009 --net myapps MyDockerImage
Now inside your MyDockerImage, mongodb can be reached at mongodb_service
Use docker compose
You can use docker-compose to run both of them as a composition
version: '3'
services:
mongo:
image: mongodb
app:
build:
context: .
ports:
- "3000-3009:3000-3009"
And now in app mongodb will be reachable with name mongo