Shell script controls the creation, deletion, startup, shutdown of Tomcat's Docker container

Source: Internet
Author: User

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 &nbsp, $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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.