Skip to content
This repository has been archived by the owner on May 29, 2021. It is now read-only.

Add mongodb-tools into image for dump and restore. #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
@@ -1,8 +1,9 @@
FROM alpine:edge

RUN apk add --no-cache mongodb
RUN apk add --no-cache mongodb mongodb-tools

VOLUME /data/db
VOLUME /data/dump
EXPOSE 27017 28017

COPY run.sh /root
Expand Down
2 changes: 1 addition & 1 deletion Makefile
@@ -1,4 +1,4 @@
VERSION = 4.0.1-0
VERSION = 4.0.1-1
IMAGE = mvertes/alpine-mongo:$(VERSION)

all:
Expand Down
23 changes: 23 additions & 0 deletions README.md
Expand Up @@ -35,6 +35,11 @@ To run a shell session:

$ docker exec -ti mongo sh

To dump data runing in mongo shell:

$ docker exec -ti mongo sh
$ mongodump -o /data/dump

To use the mongo shell client:

$ docker exec -ti mongo mongo
Expand All @@ -43,6 +48,24 @@ The mongo shell client can also be run its own container:

$ docker run -ti --rm --name mongoshell mongo host:port/db

## Sample docker-compose setting:

```
version: "3"
services:
mgdb:
image: mvertes/alpine-mongo
volumes:
- "./data:/data/db"
- "./dump:/data/dump"
restart: always
# If you want auth start, you can add that arg.
# command: [ "mongod", "--bind_ip", "0.0.0.0", "--auth" ]
command: [ "mongod", "--bind_ip", "0.0.0.0" ]
ports:
- 27017:27017
```

## Limitations

- On MacOSX, volumes located in a virtualbox shared folder are not
Expand Down
1 change: 1 addition & 0 deletions run.sh
Expand Up @@ -4,6 +4,7 @@

# Make sure that database is owned by user mongodb
[ "$(stat -c %U /data/db)" = mongodb ] || chown -R mongodb /data/db
[ "$(stat -c %U /data/db)" = mongodb ] || chown -R mongodb /data/dump

# Drop root privilege (no way back), exec provided command as user mongodb
cmd=exec; for i; do cmd="$cmd '$i'"; done
Expand Down