Sign inSign up

plaguedr/mongodb

By plaguedr

•Updated about 4 years ago

MongoDB 4.0 container, based on the Alpine edge image.

Image
0

4.7K

plaguedr/mongodb repository overview

⁠plaguedr/docker-mongodb

This repository contains Dockerfile for MongoDB 4.0 container, based on the Alpine edge image.

⁠Usage

To run mongod:

$ docker run -d --name mongo -p 27017:27017 plaguedr/mongodb:latest

You can also specify the database repository where to store the data with the volume -v option:

$ docker run -d --name mongo \
    -p 27017:27017 \
    -v <my-local-path>/mydatabase:/data/db \
    -v <my-local-path>/mybackup:/data/dump \
    -v <my-local-path>/myconfig:/data/config \
    plaguedr/mongodb:latest
⁠Volumes exposed by this container

/data/db - External mapping of the database

/data/dump - External mapping of the database backup

/data/config - Cron configuration and scripts

⁠Crontab and scripts

You can specify a crontab file and scripts (for example backup of your database.)

⁠Example

Create file <my-local-path>/config/crontab with content:

0 1 * * * /usr/local/bin/mongo-backup.sh

and another file <my-local-path>/config/mongo-backup.sh with content:

#!/bin/ash

mongodump --gzip --archive=/data/dump/dump_$(date +%d-%m-%Y"_"%H_%M).mongo.gz

find /data/dump -name "*.gz" -type f -mtime +7 -delete

The above example will take care of daily (at 1:00 AM) backup of mongodb database and will keep only 7 backups in dump directory.

Tag summary

Content type

Image

Digest

Size

206.3 MB

Last updated

about 4 years ago

docker pull plaguedr/mongodb