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

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

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

瀏覽:2日期: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
相關文章:
主站蜘蛛池模板: 黄色三级日韩 | 经典国产乱子伦精品视频 | 三级理论手机在线观看视频 | 特级毛片免费视频播放 | 精品无人区一区二区三区a 精品午夜国产在线观看不卡 | 国产精品亚洲第五区在线 | 最新国产区 | 国产乱码精品一区二区三区四川人 | 久久久久毛片免费观看 | 欧美不卡在线视频 | 九一福利视频 | 国产偷国产偷亚洲高清午夜 | 美女舒服好紧太爽了视频 | 最新国产精品好看的国产精品 | 午夜三级成人三级 | 精品在线观看国产 | 99精品久久99久久久久久 | 久久精品国产亚洲高清 | 欧美日韩第三页 | 国产精品亚洲精品久久成人 | 亚欧成人中文字幕一区 | 久草视频在线免费播放 | 精品91| 亚洲在线视频一区 | 国产aⅴ片 | 69欧美另类xxxxx高清 | 成 人免费视频l免费观看 | 国产精品高清全国免费观看 | 久久精品系列 | 中文字幕有码在线 | 国产精品一在线观看 | 成人欧美一区二区三区 | 国产免费爽爽视频免费可以看 | 亚洲欧美精品一中文字幕 | 欧美一级看片免费观看视频在线 | 欧美国产日本精品一区二区三区 | 一区二区三区国产美女在线播放 | 国产成人精品曰本亚洲 | 岛国大片在线播放免费 | 在线免费黄色网址 | 欧美视频三区 |