Skip to content

wind13/docker-alpine-mongo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

license_badge docker_build_badge idocker_image_badge docker_pulls_badge

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

Install

As a prerequisite, you need Docker to be installed.

To download this image from the public docker hub:

$ docker pull mvertes/alpine-mongo

To re-build this image from the dockerfile:

$ docker build -t mvertes/alpine-mongo .

Usage

To run mongod:

$ docker run -d --name mongo -p 27017:27017 mvertes/alpine-mongo

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 /somewhere/onmyhost/mydatabase:/data/db \
  mvertes/alpine-mongo

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

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 supported, due to a limitation of virtualbox (default docker-machine driver) not supporting fsync().

About

MongoDB Dockerfile based on light alpine container

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 55.7%
  • Dockerfile 26.2%
  • Makefile 18.1%