Difference between revisions of "Docker"

From Hawk Wiki
Jump to: navigation, search
(Docker socks5 proxy and Auto Restart)
(Docker watch logs)
 
(2 intermediate revisions by the same user not shown)
Line 12: Line 12:
 
<pre>
 
<pre>
 
docker container rm $(docker container ls -q)
 
docker container rm $(docker container ls -q)
 +
</pre>
 +
== docker check ip==
 +
<pre>docker inspect --format '{{ .NetworkSettings.IPAddress }}' mongodbmycompany2</pre>
 +
 +
==docker replica with mongodb==
 +
<pre>
 +
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")
 +
 +
</pre>
 +
==Docker watch logs==
 +
<pre>docker logs --follow $CLUSTER_NAME</pre>
 +
 +
==Docker view errors==
 +
save this as shell file and run it
 +
<pre>
 +
CONTAINER=$1
 +
docker logs --tail 500 $CONTAINER > /dev/null 2>/tmp/${CONTAINER}stderr.log && cat /tmp/${CONTAINER}stderr.log
 
</pre>
 
</pre>

Latest revision as of 21:03, 13 September 2019

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

Docker view errors

save this as shell file and run it

CONTAINER=$1
docker logs --tail 500 $CONTAINER > /dev/null 2>/tmp/${CONTAINER}stderr.log && cat /tmp/${CONTAINER}stderr.log