Public Repository

Last pushed: a year ago
Short Description
Custom mongodb for appfxdesign
Full Description

#Begin Dockerfile
FROM mongo:3.2.6

CMD ["mongod", "--config", "/data/configdb/mongod.conf"]

#end Dockerfile

docker build -t appfxdesign/mongodb .

docker run --name mongodb -d --net=light-server.net --net-alias=mongodb.light-server.net -v /data/db:/data/db -v /data/configdb:/data/configdb -p 27017:27017 appfxdesign/mongodb:3.2.6

#run docker mongodb at local development enviroment
docker run --name mongodb -d --net=light-server.net --net-alias=mongodb.light-server.net -v /Users/Administrator/data/mongodb/db:/data/db -v /Users/Administrator/data/mongodb:/data/configdb -p 27017:27017 appfxdesign/mongodb:3.2.6

#run docker mongodb-prod backup at local development enviroment
docker run --name mongodb-prod -d --net=light-server.net --net-alias=mongodb-prod.light-server.net -v /Users/Administrator/data/mongodb-prod/db:/data/db -v /Users/Administrator/data/mongodb-prod:/data/configdb -p 27018:27017 appfxdesign/mongodb:3.2.6

#run docker mongodb at local development enviroment - Replica Set ----------------

#Master
docker run --name mongodb -d --net=light-server.net --net-alias=mongodb.light-server.net -v /Users/Administrator/data/mongodb/db:/data/db -v /Users/Administrator/data/mongodb:/data/configdb -p 27017:27017 appfxdesign/mongodb:3.2.6

#Slaver
docker run --name mongodb1 -d --net=light-server.net --net-alias=mongodb1.light-server.net -v /Users/Administrator/data/mongodb1/db:/data/db -v /Users/Administrator/data/mongodb1:/data/configdb -p 27018:27017 appfxdesign/mongodb:3.2.6

#got in the mongodb
docker exec -it mongodb /bin/bash

#change host name
cfg = rs.conf()
cfg.members[0].host = "mongodb.light-server.net:27017"
rs.reconfig(cfg)

#add host
rs.add("mongodb1.light-server.net")

#enable query from secondary node:
docker exec -it mongodb1 /bin/bash
rs.slaveOk()

#prevent secondary becoming primary
cfg = rs.conf()
cfg.members[1].priority = 0
rs.reconfig(cfg)

#-----------------------------------------------------------

#systemd unit file
[Unit]
Description=Mongodb Container
After=docker.service
Requires=docker.service
After=rc.local.service

[Service]
TimeoutStartSec=0
Restart=always
ExecStart=/usr/bin/docker start mongodb

[Install]
WantedBy=multi-user.target

Docker Pull Command
Owner
appfxdesign

Comments (0)