Docker

From Hawk Wiki
Revision as of 05:53, 24 December 2018 by Hall (Talk | contribs) (docker replica with mongodb)

Jump to: navigation, search

Docker socks5 proxy and Auto Restart

run on port 21080

docker pull wernight/dante
docker run -dit --restart unless-stopped -p 21080:1080 wernight/dante

Docker mongodb

docker run -d -p 29017:27017 -v /data/db:/data/db -v /etc/mongod.conf:/etc/mongod.conf mongo:3.6.9-stretch --directoryperdb

Docker remove all stopped containers

docker container rm $(docker container ls -q)

docker check ip

docker inspect --format '{{ .NetworkSettings.IPAddress }}' mongodbmycompany2

docker replica with mongodb

docker run -d --name ${CLUSTER_NAME}1 -p 29017:27017 -v /data/$CLUSTER_NAME/db:/data/db -v /data/$CLUSTER_NAME/configData:/configData $IMAGE --directoryperdb --auth --replSet $CLUSTER_NAME --keyFile /mongo-config/mongo-keyfile --storageEngine wiredTiger

rs.initiate()
cfg = rs.conf()
cfg.members[0].host = "hostname:27017"
rs.reconfig(cfg)

rs.add("hostname2:27017")
# arbiter only node
rs.addArb("hostname3:27017")

Docker watch logs

docker logs --follow $CLUSTER_NAME