summaryrefslogtreecommitdiff
path: root/_posts/2017-03-07-use-central-mongodb-in-docker-environment.md
blob: 345b39edb39d3958270b2a1f05e9948a7b79640b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
layout: post
title: "Use a central mongodb in docker environment for differrent services"
description: ""
category: Installation
tags: [Docker, Mongodb, Database]
---
{% include JB/setup %}


**download and run the mongodb**

    docker pull mongo
    docker run --name central-mongo -d mongo

**you can define the storage engine by name**

    docker run --name central-mongo -d mongo --storageEngine wiredTiger

**start your service and link the mongodb to it**

    docker run --name my-service --link central-mongo:mongodb -d insilicotox/my-service

**enter your service container and check the central mongodb network adress**

    docker exec -ti my-service bash
    cat /etc/hosts  -> 172.17.x.x mongodb
    env|grep MONGODB  -> MongoPort = tcp://172.17.x.x:27017

**use this port for your mongo commands e.g.**

    `mongorestore --host 172.17.x.x`