Description
Multiple tomcat containers, while starting and shutting down, use pipework control for each Docker container's network management. This script is used to manage the creation, deletion, startup, and shutdown of multiple containers. The user can modify it by itself.
#!/bin/bash# chkconfig:2345 11 90# description: docker $NameBEGIN =1end=4name= Apihost= "$Name" mem=2048mcontainer_web_dir= "/tomcat/webapps" container_log_dir= "/tmp" host_web_dir= "/opt/docker/$ Name/web "host_log_dir="/opt/docker/$Name/log "ios=" 192.168.0.136:5000/singulax/tomcat:7.0.55.1 "Net=" 172.17.6 " Gateway= "$Net. 254" Create () { for (n=begin;n<=end;n++) do docker run -d --privileged --name $Name $n -h $Host $n -m $Mem --memory-swap= $Mem -v / etc/localtime:/etc/localtime -v $Host _web_dir: $Container _web_dir -v $Host _log_ DIR: $Container _log_dir $IOS docker exec - it $Name $n ifconfig eth0 down /usr/ Local/bin/pipework docker0 -i eth1 $Name $n $Net $n/[email protected] $GATEWAY done}delete () { for ((n=begin;n<=end;n++)) do docker stop $Name $n && docker rm $ Name$n done}start () { for ((n=begin;n<=end;n++)) do docker start $Name $n docker exec -it $Name $n ifconfig eth0 down /usr/local/bin/ pipework docker0 -i eth1 $Name $n $Net $n/[email protected] $GATEWAY done}stop () { for ((n=begin;n<=end;n++)) do docker stop $Name $n done}case $1 increate) echo "creating  , $Name Containner for $Name docker service " create;; Delete) echo "deleting $Name Containner for $Name docker service " delete;; Start) echo "start running $Name containner" start;; Stop) echo "stop running $Name containner" stop;; *) echo $ "Usage: $0 {start|stop|create|delete}" exit 1;; Esac
This article from the "Do not ask for the best, only better" blog, please be sure to keep this source http://yujianglei.blog.51cto.com/7215578/1725594
Shell script controls the creation, deletion, startup, shutdown of Tomcat's Docker container