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

您的位置:首頁技術文章
文章詳情頁

docker批量啟動關閉所有容器的操作

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

docker中

啟動所有的容器命令

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

docker中

關閉所有的容器命令

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

補充:shell批量啟動和刪除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

說明:containerIDs里面是你已經建好的,docker容器這里為nginx

docker批量啟動關閉所有容器的操作

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

docker批量啟動關閉所有容器的操作

docker批量啟動關閉所有容器的操作

過程稍微慢了點,耐心等待。

docker批量啟動關閉所有容器的操作

停止容器成功。

啟動容器

#!/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批量啟動關閉所有容器的操作

docker批量啟動關閉所有容器的操作

docker批量啟動關閉所有容器的操作

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。如有錯誤或未考慮完全的地方,望不吝賜教。

標簽: Docker
相關文章:
主站蜘蛛池模板: 亚洲免费网 | 国产亚洲一区呦系列 | 欧美日韩视频一区二区在线观看 | 中国一级毛片免费观看 | avhd101天天看新片 | 亚洲男人天| 精品自拍视频在线观看 | a级毛片高清免费视频 | 亚洲成成品网站有线 | 伊人色综合久久成人 | 欧美精品人爱c欧美精品 | a毛片免费视频 | 91久久国产精品视频 | 国产高清天干天天视频 | 在线成人a毛片免费播放 | 亚洲一区免费视频 | 中文字幕亚洲另类天堂 | 亚洲人成网站观看在线播放 | 在线免费观看亚洲视频 | 草久在线观看 | 小明日韩在线看看永久区域 | 性生活视频网 | 久久国产影视免费精品 | 另类视频综合 | 精品国产一区在线观看 | 99久久99久久久99精品齐 | 成人免费视频一区二区 | 欧美一级日本一级韩国一级 | 久久成人福利视频 | 99精品久久久久久久 | 国产成人福利视频在线观看 | 亚洲欧美日韩专区 | 成人爽a毛片在线视频网站 成人爽爽大片在线观看 | 久久久久18 | 91av福利| 久久久久国产成人精品亚洲午夜 | 精品国产免费第一区二区三区日韩 | 国产在线一区二区三区在线 | 成人福利网站在线看视频 | 男女无遮挡拍拍拍免费1000 | 精品国产一区二区二三区在线观看 |