国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

docker批量啟動(dòng)關(guān)閉所有容器的操作

瀏覽:2日期:2024-10-29 18:38:20

docker中

啟動(dòng)所有的容器命令

docker start $(docker ps -a | awk ’{ print $1}’ | tail -n +2)

docker中

關(guān)閉所有的容器命令

docker stop $(docker ps -a | awk ’{ print $1}’ | tail -n +2)

補(bǔ)充:shell批量啟動(dòng)和刪除docker容器,基于docker toolbox

停止容器

stop.sh#!/bin/bashcontainerIDs='8f78b7e6995b beeae59c6f41 5305c3db3670 bffc551a6b96 61f0fc8b1dc4 8e85a3b7bfe3 d15c4d2dc546 2a3c4eb14584 5e98077acc3a 13bac087b83d'statusLived='live'statusdead='Dead'notExistContainer='None'retryCount=3function GetContainerStatus(){ containerExist=$(docker ps -a | grep -i $1 | wc -l ) if [ ${containerExist} -gt 0 ] then pid=$(docker stats --format '{{.PIDs}}' --no-stream $1 ) if [ '${pid}' != '0' ] then echo '${statusLived}' else echo '${statusdead}' fi else echo '${notExistContainer}' fi}function StopContainer(){ docker stop $1}for containerID in ${containerIDs} do for ((i=1;i<=${retryCount};i++)) do status=$(GetContainerStatus ${containerID} ) echo 'Container ${containerID} status is ${status}' if [ '${status}' == ${statusdead} ] then echo 'Container ${containerID} already stopped' break fi if [ '${status}' == ${notExistContainer} ] then echo 'Container ${containerID} not existed' break fi if [ '${status}' == ${statusLived} ] then echo 'Container ${containerID} is lived ,stop container' StopContainer ${containerID} verifyStatus=$(GetContainerStatus ${containerID} ) if [ '${verifyStatus}' == ${statusdead} ] then echo 'stop container ${containerID} success ' break else echo '${i} retry stop container' StopContainer ${containerID} fi fi donedone

說(shuō)明:containerIDs里面是你已經(jīng)建好的,docker容器這里為nginx

docker批量啟動(dòng)關(guān)閉所有容器的操作

把stop.sh放在d:/nginx下面。

docker批量啟動(dòng)關(guān)閉所有容器的操作

docker批量啟動(dòng)關(guān)閉所有容器的操作

過(guò)程稍微慢了點(diǎn),耐心等待。

docker批量啟動(dòng)關(guān)閉所有容器的操作

停止容器成功。

啟動(dòng)容器

#!/bin/bashcontainerIDs='8f78b7e6995b beeae59c6f41 5305c3db3670 bffc551a6b96 61f0fc8b1dc4 8e85a3b7bfe3 d15c4d2dc546 2a3c4eb14584 5e98077acc3a 13bac087b83d'statusLived='live'statusdead='Dead'notExistContainer='None'retryCount=3function GetContainerStatus(){ containerExist=$(docker ps -a | grep -i $1 | wc -l ) if [ ${containerExist} -gt 0 ] then pid=$(docker stats --format '{{.PIDs}}' --no-stream $1 ) if [ '${pid}' != '0' ] then echo '${statusLived}' else echo '${statusdead}' fi else echo '${notExistContainer}' fi}function StartContainer(){ docker restart $1}for containerID in ${containerIDs} do for((i=1;i<=${retryCount};i++)) do status=$(GetContainerStatus ${containerID} ) echo 'Container ${containerID} status is ${status}' if [ '${status}' == ${statusLived} ] then echo 'Container ${containerID} already running' break fi if [ '${status}' == ${notExistContainer} ] then echo 'Container ${containerID} not existed' break fi if [ '${status}' == ${statusdead} ] then echo 'Container ${containerID} stopped ,start container' StartContainer ${containerID} verifyStatus=$(GetContainerStatus ${containerID} ) if [ '${verifyStatus}' == ${statusLived} ] then echo 'start container ${containerID} success ' break else echo '${i} retry start container' StartContainer ${containerID} fi fi donedone

docker批量啟動(dòng)關(guān)閉所有容器的操作

docker批量啟動(dòng)關(guān)閉所有容器的操作

docker批量啟動(dòng)關(guān)閉所有容器的操作

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。

標(biāo)簽: Docker
相關(guān)文章:
主站蜘蛛池模板: 夜夜爽影院 | 在线精品播放 | 九九视频精品在线 | 亚洲国产成人麻豆精品 | 亚洲欧美自拍视频 | 亚洲国产精品久久久久秋霞不卡 | 99在线免费观看视频 | 美女张开大腿让男人桶 | 欧美另类孕交免费观看 | 亚洲欧美视频在线观看 | 日本免费的一级绿象 | 成人毛片1024你懂的 | 伊人色综合久久成人 | 91国内精品久久久久影院优播 | 亚洲国产一区二区a毛片 | 国产欧美一区二区精品久久久 | 美国一级毛片片aaa 美国一级毛片片aa成人 | 老王午夜69精品影院 | 黄色不卡视频 | 国产综合久久一区二区三区 | 在线看片亚洲 | 欧美xxxxx色视频在线观看 | 国产亚洲精品久久久久久久网站 | 91在线亚洲| 日韩一品在线播放视频一品免费 | 日本欧美亚洲 | 日本韩国一级毛片中文字幕 | 97在线视频免费观看 | 久久久毛片 | 美女视频黄色网址 | 丁香婷婷影音先锋5566 | 欧美在线精品一区二区三区 | 国内国外精品一区二区 | 67id人成国产在线 | 久久综合99re久久爱 | 毛片高清一区二区三区 | 96精品视频在线播放免费观看 | 一级黄片毛片 | 欧美成人手机视频 | 99久久精品免费国产一区二区三区 | 久久国产a|