Public Repository

Last pushed: 2 years ago
Short Description
MongoDB 3.2.0
Full Description

The current version (3.2.0) of this image contains

  • ubuntu:14.04
  • mongodb:3.2.0

Notes to persistence

If you stop the docker container, everything on the containers filesystem is lost! That isn't really good for a database container :-) But luckily it is possible to mount directories from the Host into the docker container, so called volumes. That is the place there you can store data permanently.

MongoDB stores his files by default into the /data directory. By starting the docker container you can mount a host directory into /data. Let's call that persistent host directory YOUR_LOCAL_DATA_DIR.

Configure it

You have to add a mongod.conf file in the root of YOUR_LOCAL_DATA_DIR. The instance expects their the main configuration file. If the file mongod.conf is not their the container will exit with an error code!

Run it

You can run it like this:

> docker run --name mongodb -v <YOUR_LOCAL_DATA_DIR>:/data -p 27017:27017
> -p 28017:28017 -d reiz/mongodb:1.0.2

For example:

> docker run --name mongodb -v /mnt/mongodb:/data -p 27017:27017
> -p 28017:28017 -d reiz/mongodb:1.0.2

In that example YOUR_LOCAL_DATA_DIR is /mnt/mongodb.

Under your YOUR_LOCAL_DATA_DIR there should be a db directory. MongoDB is expecting that. If that subdirectory is missing the container will exit with an error code.

Logging

By default the container will log to stdout and you can watch the logs with this command

> docker logs mongodb

If you want to persist the logs add this line to your mongod.conf:

> logpath=/data/logs/mongodb.log

And create a logs directory under YOUR_LOCAL_DATA_DIR. Than all the logs will be written to YOUR_LOCAL_DATA_DIR/logs/mongodb.log.

Dockerfile

Here is the Dockerfile I used to build this image: https://gist.github.com/reiz/a2b76b37279c4fd11287

Docker Pull Command
Owner
reiz

Comments (0)