-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (44 loc) · 1.42 KB
/
Dockerfile
File metadata and controls
53 lines (44 loc) · 1.42 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#
# Program: Dockerfile for MongoDB ReplicaSet
# Authors: zhezhang
# History:
# 2017/06/21: build mgo image with centos
# 2017/07/19: update: build mgo image with alpine
#
# Build Images:
# docker build -t <image_name> .
# docker build --no-cache -t mgors:base
#
# Run Container:
# docker run --name <container_name> --net docker1 --ip 172.18.0.167 --restart always -v <host_dir>:<container_dir> -d mgors:base
# eg: docker run --name rs1 --net docker1 --ip 172.18.0.167 --restart always -v /home/mgors/rs1:/home/mgo -d mgors:base
#
# Start·Stop:
# docker start|stop container_name
#
# Delete:
# docker rm -v container_name
#
# Get Container Ip:
# docker-ip container_name ...
#
# Entry Container
# docker exec -it container_name /bin/bash
#
FROM alpine:latest
ENV MgoHome=/home/mgo
MAINTAINER <xxx@163.com>
WORKDIR ${MgoHome}
RUN apk update \
&& apk add mongodb --no-cache --repository http://dl-4.alpinelinux.org/alpine/edge/testing --allow-untrusted \
&& rm -rf /var/cache/apk/*
RUN echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/main' > /etc/apk/repositories \
&& echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/community' >> /etc/apk/repositories \
&& apk update && apk add tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& mkdir -p ${MgoHome}/data/db \
&& touch ${MgoHome}/mongod.log
EXPOSE 27017
COPY mongod.conf mongodkey run.sh ${MgoHome}/
CMD ["./run.sh"]