Shell腳本構建Docker 半自動化編譯打包發佈應用操作
Docker 發佈的方式為實現DevOps(自動化運維,需要配置 代碼管理工具如Git的hook來實現提交編譯、打包、發佈等一系列事件控制)提供瞭諸多方便,輔助於Shell腳本可以很好的配合起來。
Docker鏡像可以通過自動化編譯,也可以通過導入鏡像的方式來獲得。
本文的題目叫:Shell腳本構建Docker 半自動化編譯打包發佈,因為我這裡還沒跟代碼管理關聯起來。
Shell腳本不同實現
導入鏡像方式(鏡像文件rtvsweb-publish.tar):
構建發佈方式(依靠Dockerfile來構建):
Shell Docker構建發佈腳本工具核心install.sh
#! /bin/bash ##file:rtvs.sh ##company:cvnavi.com ##author:Pengjunlin echo "當前執行文件......$0" ##################################變量定義################################## DOCKER_IMAGE_IS_MATCH_TAR_FILE="false" DOCKER_RTVSWEB_CONTAINER_NAME="rtvsweb-publish" DOCKER_RTVSWEB_NEW_VERSION="" DOCKER_RTVSWEB_FIRST_VERSION=1 DOCKER_RTVSWEB_SECOND_VERSION=0 DOCKER_RTVSWEB_THIRD_VERSION=0 DOCKER_RTVSWEB_VERSION_TAG="" DOCKER_CONTAINER_TEMP_HOST="" DB_REDIS_CONNECTION_STRING="" DB_MYSQL_CONNECTION_STRING="" DB_MYSQL_HOST="" MASTER_LAN_IP="" SYSTEM_ALLOW_TO_SET="false" ###################################函數定義####################################### function init_files() { # 創建rtvs目錄 if [[ ! -d "/usr/local/rtvs" ]]; then echo "創建容器映射路徑.... /usr/local/rtvs" mkdir /usr/local/rtvs fi # 復制VersionConfig.xml(第一次做完全復制,若有變動需要手動修改) if [[ -f "./VersionConfig.xml" ]]; then if [[ ! -f "/usr/local/rtvs/VersionConfig.xml" ]]; then echo "拷貝一份XML配置文件: ./VersionConfig.xml /usr/local/rtvs/VersionConfig.xml" cp VersionConfig.xml /usr/local/rtvs/VersionConfig.xml fi else echo "缺少./VersionConfig.xml文件...已退出安裝!" exit fi # 復制SettingConfig.xml(第一次做完全復制,若有變動需要手動修改) if [[ -f "./SettingConfig.xml" ]]; then if [[ ! -f "/usr/local/rtvs/SettingConfig.xml" ]]; then echo "拷貝一份XML配置文件: ./SettingConfig.xml /usr/local/rtvs/SettingConfig.xml" cp SettingConfig.xml /usr/local/rtvs/SettingConfig.xml fi else echo "缺少./SettingConfig.xml文件...已退出安裝!" exit fi # 復制log4.config(第一次做完全復制,若有變動需要手動修改) if [[ -f "./log4.config" ]]; then if [[ ! -f "/usr/local/rtvs/log4.config" ]]; then echo "拷貝一份日志配置文件: ./log4.config /usr/local/rtvs/log4.config" cp log4.config /usr/local/rtvs/log4.config fi else echo "缺少./log4.config文件...已退出安裝!" exit fi } function mysql_create_table() { if [[ -f "./mysql_create_table.sh" ]]; then echo "數據庫腳本賦值權限......" # 為執行文件添加權限 chmod a+x mysql_create_table.sh else echo "缺少./mysql_create_table.sh文件...已退出安裝!" exit fi # 執行mysql數據庫表創建 ./mysql_create_table.sh if [[ $? -eq 0 ]]; then echo "./mysql_docker_install.sh 執行完成!" else exit fi } function docker_install() { echo "檢查Docker......" docker -v if [ $? -eq 0 ]; then echo "檢查到Docker已安裝!" else echo "安裝docker環境..." curl -sSL https://get.daocloud.io/docker | sh echo "安裝docker環境...安裝完成!" fi # 創建公用網絡==bridge模式 #docker network create share_network } function mysql_install(){ install_type=$1 if [[ "$install_type" == "by_local_mysql_installer" ]]; then #statements echo "暫不支持wget本地下載安裝,已退出!" exit 1 fi if [[ "$install_type" == "by_docker_mysql_installer" ]]; then #statements docker_mysql_install fi if [[ "$install_type" == "by_smart_installer" ]]; then #statements if [[ `netstat -lanp|grep tcp|grep 3306|wc -l` == 1 ]]; then echo "檢測到mysql已在本機安裝!" # 打印一下mysql版本 echo "檢測到mysql版本:" mysql --version # 執行創建Mysql數據庫腳本 mysql_create_table if [[ $? -eq 0 ]]; then echo "本地MySQL腳本初始化完成!" else echo "本地MySQL腳本初始化失敗!" exit 1 fi DB_MYSQL_HOST="localhost" else docker_mysql_install fi fi } function docker_mysql_install(){ echo "安裝Docker Mysql環境..." if [[ -f "./docker_mysql_install.sh" ]]; then if [[ -f "./docker_mysql_create_table.sh" ]]; then echo "拷貝一份容器執行文件: ./docker_mysql_create_table.sh /usr/local/docker_mysql_create_table.sh" cp docker_mysql_create_table.sh /usr/local/docker_mysql_create_table.sh else echo "缺少./docker_mysql_create_table.sh文件...已退出安裝!" exit 1 fi # 為執行文件添加權限 chmod a+x docker_mysql_install.sh # Dokcer方式安裝Mysql ./docker_mysql_install.sh if [[ $? -eq 0 ]]; then echo "./docker_mysql_install.sh 執行完成!" # 休10秒鐘 echo "休眠等待10s,等待Docker執行完成......" sleep 10s # 測試打印mysql信息 print_docker_mysql_info else echo "./docker_mysql_install.sh 執行過程中出現錯誤,已退出安裝!" exit 1 fi else echo "缺少./docker_mysql_install.sh文件...已退出安裝!" exit 1 fi } function docker_container_ip() { DOCKER_CONTAINER_TEMP_HOST=` docker inspect --format '{{ .NetworkSettings.IPAddress }}' $1` } function init_docker_master_ip(){ out=0 for i in `ip a |grep inet[^6]|grep -E -o '([0-9]{1,3}\.){3}[0-9]{1,3}'`; do OLD_IFS="$IFS" IFS="." arr=($i) IFS="$OLD_IFS" for s in ${arr[@]} ;do if [[ $s -eq "192" ]]; then echo "$i" MASTER_LAN_IP=$i out=1 break fi done if [[ $out -eq 1 ]]; then break fi done } function print_docker_mysql_info() { echo "腳本執行Mysql信息驗證:..." if [[ -f "./docker_mysql_validator.sh" ]]; then echo "拷貝一份容器執行文件: ./docker_mysql_validator.sh /usr/local/docker_mysql_validator.sh" cp docker_mysql_validator.sh /usr/local/docker_mysql_validator.sh else echo "缺少./docker_mysql_validator.sh文件...已退出安裝!" exit fi # 映射copy文件路徑到docker容器 docker cp /usr/local/docker_mysql_validator.sh mysql5.7:/usr/local/docker_mysql_validator.sh docker exec -it mysql5.7 /bin/bash -c "sh /usr/local/docker_mysql_validator.sh" if [[ $? -eq 0 ]]; then echo "./docker_mysql_validator.sh 執行完成!" echo "MySQL容器Host:" docker_container_ip mysql5.7 echo "當前mysql5.7實例IP=$DOCKER_CONTAINER_TEMP_HOST" #echo "MySQL容器network 相關信息:" #docker network inspect share_network #echo "MySQL容器link相關信息:" #cat /etc/hosts else echo "./docker_mysql_validator.sh 執行過程中出現錯誤,已退出安裝!" exit fi #link 訪問方式 DB_MYSQL_HOST="mysql5.7" } function destory_docker_service() { # 停止容器 for i in [ `docker ps ` ]; do if [[ "$i" == "rtvsweb-publish" ]]; then echo "嘗試停止$DOCKER_RTVSWEB_CONTAINER_NAME容器..." docker stop $DOCKER_RTVSWEB_CONTAINER_NAME fi done # 刪除容器 for i in [ `docker ps -a` ]; do if [[ "$i" == "rtvsweb-publish" ]]; then echo "嘗試刪除$DOCKER_RTVSWEB_CONTAINER_NAME容器..." docker rm $DOCKER_RTVSWEB_CONTAINER_NAME fi done } function docker_build_image() { # 清理容器(保留歷史構建的鏡像) destory_docker_service if [[ $? -eq 0 ]]; then echo "應用服務容器和鏡像已處理,配置文件已完成復制!" else exit 1 fi echo "Docker鏡像構建......cmd:(docker build -t rtvsweb:$DOCKER_RTVSWEB_NEW_VERSION .)" docker build -t rtvsweb:$DOCKER_RTVSWEB_NEW_VERSION . # 判斷是否有鏡像,存在時創建相應的容器實例 for i in [ `docker images` ]; do #statements if [[ "$i" == "$DOCKER_RTVSWEB_NEW_VERSION" ]]; then DOCKER_IMAGE_IS_MATCH_TAR_FILE="true" echo "已經找到最新構建的鏡像!" run_docker_service_image break fi done if [[ $DOCKER_IMAGE_IS_MATCH_TAR_FILE == "false" ]]; then echo "構建鏡像未匹配到最新版本,已退出安裝!" exit 1 fi echo "構建後的docker images鏡像列表:" docker images echo "當前正在運行的Docker容器實例列表:" docker ps } function run_docker_service_image() { echo "正在啟動docker 服務容器......" # run 的參數設置參考VS項目啟動的設置--privileged=true 獲取管理員權限 # ===bridge 橋接模式 #docker run -it --name=$DOCKER_RTVSWEB_CONTAINER_NAME --net="bridge" --dns 8.8.8.8 --network share_network --network-alias $4 -v /usr/local/rtvs/error_log:/app/Error_log -v /usr/local/rtvs/log_file:/app/LogFile -v /usr/local/rtvs/mydata:/MyData -v /usr/local/rtvs/videocache:/MyVideo -v /usr/local/rtvs/SettingConfig.xml:/app/SettingConfig.xml -p 38067:80 -p 44383:443 -p 18000:18000 -p 18002:18002 -p 19700:19700 -p 19702:19702 -p 19703:19703 -d $DOCKER_RTVSWEB_IMAGE_TAG_NAME if [[ $DB_MYSQL_HOST == "mysql5.7" ]]; then # ===link 鏈接模式 echo "rtvsweb--容器運行---鏈接模式" docker run -it --name $DOCKER_RTVSWEB_CONTAINER_NAME --privileged=true --link mysql5.7:mysql5.7 -v /usr/local/rtvs:/MyData -e MyDataPath=/MyData -p 38067:80 -p 44383:443 -p 18000:18000 -p 18002:18002 -p 19700-19719:19700-19719 -p 30888-30889:30888-30889 -d rtvsweb:$DOCKER_RTVSWEB_NEW_VERSION else # ===普通模式 echo "rtvsweb--容器運行---普通模式" docker run -it --name $DOCKER_RTVSWEB_CONTAINER_NAME --privileged=true -v /usr/local/rtvs:/MyData -e MyDataPath=/MyData -p 38067:80 -p 44383:443 -p 18000:18000 -p 18002:18002 -p 19700-19719:19700-19719 -p 30888-30889:30888-30889 -d rtvsweb:$DOCKER_RTVSWEB_NEW_VERSION fi } ####################工具類和流程定制################################ function editXml() { val=`echo ${@:3}` echo "正在修改XML文件:$1...." echo "正在修改XML文件:[0]=$1,[1]=$2,[2]=$val" echo "XML文件$2標簽 value=$val" sed -i "s/<$2>.*<\/$2>/<$2>${val}<\/$2></g" $1 } function init_mysql_conn() { if [[ "$DB_MYSQL_HOST" == "localhost" ]]; then mysql="Database=filecache;Data Source=$MASTER_LAN_IP;port=3366;User Id=rtvsweb;Password=rtvs2018;charset=utf8;pooling=true" sed -i "s/<MysqlConnectionString>.*<\/MysqlConnectionString>/<MysqlConnectionString>$mysql<\/MysqlConnectionString>/g" /usr/local/rtvs/SettingConfig.xml DB_MYSQL_CONNECTION_STRING=`grep -E -o -e '<MysqlConnectionString>.+</MysqlConnectionString>' /usr/local/rtvs/SettingConfig.xml | sed 's/<MysqlConnectionString>//g'|sed 's/<\/MysqlConnectionString>//g'` else mysql="Database=filecache;Data Source=mysql5.7;port=3306;User Id=rtvsweb;Password=rtvs2018;charset=utf8;pooling=true" sed -i "s/<MysqlConnectionString>.*<\/MysqlConnectionString>/<MysqlConnectionString>$mysql<\/MysqlConnectionString>/g" /usr/local/rtvs/SettingConfig.xml DB_MYSQL_CONNECTION_STRING=`grep -E -o -e '<MysqlConnectionString>.+</MysqlConnectionString>' /usr/local/rtvs/SettingConfig.xml | sed 's/<MysqlConnectionString>//g'|sed 's/<\/MysqlConnectionString>//g'` fi } function editSpecificConfig() { init_mysql_conn echo "獲取/usr/local/rtvs/SettingConfig.xml信息..." cat /usr/local/rtvs/SettingConfig.xml # 判斷是否可以設置 if [[ "$SYSTEM_ALLOW_TO_SET" == "true" ]]; then read -p ">>>是否修改Redis配置連接字符串?y/n:" ans echo "$ans" if [[ "$ans" == "y" ]]; then read -p "請輸入Redis配置連接字符串:" redis echo "新的Redis連接字符串:$redis" sed -i "s/<RedisExchangeHosts>.*<\/RedisExchangeHosts>/<RedisExchangeHosts>$redis<\/RedisExchangeHosts>/g" /usr/local/rtvs/SettingConfig.xml DB_REDIS_CONNECTION_STRING=`grep -E -o -e '<RedisExchangeHosts>.+</RedisExchangeHosts>' /usr/local/rtvs/SettingConfig.xml | sed 's/<RedisExchangeHosts>//g'|sed 's/<\/RedisExchangeHosts>//g'` echo "獲取已修改的Redis配置連接字符串...RedisExchangeHosts=$DB_REDIS_CONNECTION_STRING" fi read -p ">>>是否修改Mysql配置連接字符串?y/n:" ans echo "$ans" if [[ "$ans" == "y" ]]; then read -p "請輸入Mysql配置連接字符串:" mysql echo "新的Mysql連接字符串:$mysql" sed -i "s/<MysqlConnectionString>.*<\/MysqlConnectionString>/<MysqlConnectionString>$mysql<\/MysqlConnectionString>/g" /usr/local/rtvs/SettingConfig.xml DB_MYSQL_CONNECTION_STRING=`grep -E -o -e '<MysqlConnectionString>.+</MysqlConnectionString>' /usr/local/rtvs/SettingConfig.xml | sed 's/<MysqlConnectionString>//g'|sed 's/<\/MysqlConnectionString>//g'` echo "獲取已修改的Mysql配置連接字符串...MysqlConnectionString=$DB_MYSQL_CONNECTION_STRING" fi fi } function remoteRedisAndMysqlConfig() { echo "獲取/usr/local/rtvs/SettingConfig.xml信息..." cat /usr/local/rtvs/SettingConfig.xml # 設置Redis連接字符串 read -p "是否修改Redis配置連接字符串?y/n:" ans echo "$ans" if [[ "$ans" == "y" ]]; then read -p "請輸入Redis連接字符串:" redis echo "新的Redis連接字符串:$redis" sed -i "s/<RedisExchangeHosts>.*<\/RedisExchangeHosts>/<RedisExchangeHosts>$redis<\/RedisExchangeHosts>/g" /usr/local/rtvs/SettingConfig.xml DB_REDIS_CONNECTION_STRING=`grep -E -o -e '<RedisExchangeHosts>.+</RedisExchangeHosts>' /usr/local/rtvs/SettingConfig.xml | sed 's/<RedisExchangeHosts>//g'|sed 's/<\/RedisExchangeHosts>//g'` echo "獲取已修改的Redis配置連接字符串...RedisExchangeHosts=$DB_REDIS_CONNECTION_STRING" fi read -p "是否修改Mysql配置連接字符串?y/n:" ans echo "$ans" if [[ "$ans" == "y" ]]; then read -p "請輸入Mysql連接字符串:" mysql echo "新的Mysql連接字符串:$mysql" sed -i "s/<MysqlConnectionString>.*<\/MysqlConnectionString>/<MysqlConnectionString>$mysql<\/MysqlConnectionString>/g" /usr/local/rtvs/SettingConfig.xml DB_MYSQL_CONNECTION_STRING=`grep -E -o -e '<MysqlConnectionString>.+</MysqlConnectionString>' /usr/local/rtvs/SettingConfig.xml | sed 's/<MysqlConnectionString>//g'|sed 's/<\/MysqlConnectionString>//g'` echo "獲取已修改的Mysql配置連接字符串...MysqlConnectionString=$DB_MYSQL_CONNECTION_STRING" fi } function help() { echo "*******************************************" echo "********* 調用方法說明 ************" echo "*******************************************" echo "查看核心配置文件:cat ./SettingConfig.xml" echo "幫助方法說明:sh ./install.sh help" echo "修改Redis和MySQL連接字符串:sh ./install.sh editXml [XMLFilePath] [tag] ['value'] " echo "********************************************" echo "********* 快速定制安裝 *************" echo "********************************************" echo "1、執行本地Mysql安裝(wget下載文件安裝...比較費時): sh ./install.sh by_local_mysql_installer" echo "2、執行Docker Mysql安裝 : sh ./install.sh by_docker_mysql_installer" echo "3、智能檢測決定Mysql安裝方式(如果本機已有MySQL則直接使用): sh ./install.sh by_smart_installer" echo "4、簡化安裝隻需要給出Redis和MySQL連接字符串即可(極簡方式): sh ./install.sh by_simple_installer" echo "說明:\r 以上4種方式已包含瞭Docker應用的安裝!" } function completed() { echo "******************安裝結果:*****************" # bridge 橋接模式 #echo "network實例, share_network相關容器信息:" #docker network inspect share_network version_step=1 # 記錄下一次版本號 if [[ "$DOCKER_RTVSWEB_VERSION_TAG" == "VersionFirst" ]]; then DOCKER_RTVSWEB_FIRST_VERSION=$((DOCKER_RTVSWEB_FIRST_VERSION+version_step)) sed -i "s/<VersionFirst>.*<\/VersionFirst>/<VersionFirst>$DOCKER_RTVSWEB_FIRST_VERSION<\/VersionFirst>/g" /usr/local/rtvs/VersionConfig.xml sed -i "s/<VersionSecond>.*<\/VersionSecond>/<VersionSecond>0<\/VersionSecond>/g" /usr/local/rtvs/VersionConfig.xml sed -i "s/<VersionThird>.*<\/VersionThird>/<VersionThird>0<\/VersionThird>/g" /usr/local/rtvs/VersionConfig.xml fi if [[ "$DOCKER_RTVSWEB_VERSION_TAG" == "VersionSecond" ]]; then DOCKER_RTVSWEB_SECOND_VERSION=$((DOCKER_RTVSWEB_SECOND_VERSION+version_step)) sed -i "s/<VersionSecond>.*<\/VersionSecond>/<VersionSecond>$DOCKER_RTVSWEB_SECOND_VERSION<\/VersionSecond>/g" /usr/local/rtvs/VersionConfig.xml sed -i "s/<VersionThird>.*<\/VersionThird>/<VersionThird>0<\/VersionThird>/g" /usr/local/rtvs/VersionConfig.xml fi if [[ "$DOCKER_RTVSWEB_VERSION_TAG" == "VersionThird" ]]; then DOCKER_RTVSWEB_THIRD_VERSION=$((DOCKER_RTVSWEB_THIRD_VERSION+version_step)) sed -i "s/<VersionThird>.*<\/VersionThird>/<VersionThird>$DOCKER_RTVSWEB_THIRD_VERSION<\/VersionThird>/g" /usr/local/rtvs/VersionConfig.xml fi VIDEO_CACHE_PATH=`grep -E -o -e '<VideoCachePath>.+</VideoCachePath>' /usr/local/rtvs/SettingConfig.xml | sed 's/<VideoCachePath>//g'|sed 's/<\/VideoCachePath>//g'` DB_REDIS_CONNECTION_STRING=`grep -E -o -e '<RedisExchangeHosts>.+</RedisExchangeHosts>' /usr/local/rtvs/SettingConfig.xml | sed 's/<RedisExchangeHosts>//g'|sed 's/<\/RedisExchangeHosts>//g'` DB_MYSQL_CONNECTION_STRING=`grep -E -o -e '<MysqlConnectionString>.+</MysqlConnectionString>' /usr/local/rtvs/SettingConfig.xml | sed 's/<MysqlConnectionString>//g'|sed 's/<\/MysqlConnectionString>//g'` echo "Redis連接字符串:$DB_REDIS_CONNECTION_STRING" echo "Mysql連接字符串:$DB_MYSQL_CONNECTION_STRING" echo "默認視頻緩存目錄:$VIDEO_CACHE_PATH" echo "正在運行的容器實例:" docker ps echo "容器對應的Ip地址:" docker_container_ip mysql5.7 if [[ "$DOCKER_CONTAINER_TEMP_HOST" != "" ]]; then echo "mysql5.7 ---------------------$DOCKER_CONTAINER_TEMP_HOST" fi docker_container_ip $DOCKER_RTVSWEB_CONTAINER_NAME echo "$DOCKER_RTVSWEB_CONTAINER_NAME ---------------------$DOCKER_CONTAINER_TEMP_HOST" echo "驗證rtvs訪問:curl http://cvtsp.com:38067/" echo "******************安裝完成!*****************" } function version_management() { DOCKER_RTVSWEB_FIRST_VERSION=`grep -E -o -e '<VersionFirst>.+</VersionFirst>' /usr/local/rtvs/VersionConfig.xml | sed 's/<VersionFirst>//g'|sed 's/<\/VersionFirst>//g'` DOCKER_RTVSWEB_SECOND_VERSION=`grep -E -o -e '<VersionSecond>.+</VersionSecond>' /usr/local/rtvs/VersionConfig.xml | sed 's/<VersionSecond>//g'|sed 's/<\/VersionSecond>//g'` DOCKER_RTVSWEB_THIRD_VERSION=`grep -E -o -e '<VersionThird>.+</VersionThird>' /usr/local/rtvs/VersionConfig.xml | sed 's/<VersionThird>//g'|sed 's/<\/VersionThird>//g'` DOCKER_RTVSWEB_VERSION_TAG=`grep -E -o -e '<UpgradeTag>.+</UpgradeTag>' /usr/local/rtvs/VersionConfig.xml | sed 's/<UpgradeTag>//g'|sed 's/<\/UpgradeTag>//g'` DOCKER_RTVSWEB_NEW_VERSION="$DOCKER_RTVSWEB_FIRST_VERSION.$DOCKER_RTVSWEB_SECOND_VERSION.$DOCKER_RTVSWEB_THIRD_VERSION" echo "當前rtvsweb版本:$DOCKER_RTVSWEB_NEW_VERSION" echo "當前rtvsweb版本升級格式:$DOCKER_RTVSWEB_VERSION_TAG" } function by_local_mysql_installer() { # Docker 安裝 docker_install # Mysql 安裝及其腳本創建 mysql_install "by_local_mysql_installer" # 鏡像構建 if [[ $? -eq 0 ]]; then docker_build_image if [[ $? -eq 0 ]]; then echo "鏡像構建成功!" else echo "鏡像構建失敗!" exit fi else exit fi # 修改鏡像使用的路徑和數據源 editSpecificConfig # 完成後輸出 completed } function by_docker_mysql_installer() { # Docker 安裝 docker_install # Mysql 安裝及其腳本創建 mysql_install "by_docker_mysql_installer" # 鏡像構建 if [[ $? -eq 0 ]]; then docker_build_image if [[ $? -eq 0 ]]; then echo "鏡像構建成功!" else echo "鏡像構建失敗!" exit fi else exit fi # 修改鏡像使用的路徑和數據源 editSpecificConfig # 完成後輸出 completed } function by_smart_installer() { # Docker 安裝 docker_install # Mysql 安裝及其腳本創建 mysql_install "by_smart_installer" # 鏡像構建 if [[ $? -eq 0 ]]; then docker_build_image if [[ $? -eq 0 ]]; then echo "鏡像構建成功!" else echo "鏡像構建失敗!" exit fi else exit fi # 修改鏡像使用的路徑和數據源 editSpecificConfig # 完成後輸出 completed } function by_simple_installer() { # Docker 安裝 docker_install # 鏡像構建 docker_build_image if [[ $? -eq 0 ]]; then echo "鏡像構建成功!" else echo "鏡像構建失敗!" exit fi # 修改鏡像使用的路徑和數據源 remoteRedisAndMysqlConfig # 完成後輸出 completed } if [[ $# -gt 0 ]]; then echo "安裝所需文件檢查...." init_files if [[ $? -eq 0 ]]; then echo "安裝Docker服務的文件存在,驗證通過!" else echo "安裝Docker服務的文件存在缺失,已退出安裝!" exit fi echo "rtvsweb版本檢查...." version_management echo "獲取本地局域網IP地址...." init_docker_master_ip echo "本地IP地址....MASTER_LAN_IP=$MASTER_LAN_IP" #statements if [[ "$1" == "by_local_mysql_installer" ]]; then #statements by_local_mysql_installer fi if [[ "$1" == "by_docker_mysql_installer" ]]; then #statements by_docker_mysql_installer fi if [[ "$1" == "by_smart_installer" ]]; then #statements by_smart_installer fi if [[ "$1" == "by_simple_installer" ]]; then #statements by_simple_installer fi if [[ "$1" == "editXml" ]]; then if [[ $# -eq 4 ]]; then #statements editXml $2 $3 $4 else echo "editXml參數個數不匹配!" fi fi if [[ "$1" == "help" ]]; then #statements help fi else help fi
整體設計實現思路
1、Docker環境準備和安裝
2、MySQL環境準備和安裝
3、Docker的知識:構建、運行
4、Docker鏡像的版本管理
5、容期間網絡訪問:–link
6、鏡像打包歷史
7、服務運行效果
以上為個人經驗,希望能給大傢一個參考,也希望大傢多多支持WalkonNet。如有錯誤或未考慮完全的地方,望不吝賜教。
推薦閱讀:
- None Found