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/bash
containerIDs=”8f78b7e6995b beeae59c6f41 5305c3db3670 bffc551a6b96 61f0fc8b1dc4 8e85a3b7bfe3 d15c4d2dc546 2a3c4eb14584 5e98077acc3a 13bac087b83d”
statusLived=”live”
statusdead=”Dead”
notExistContainer=”None”
retryCount=3
function 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
暂无评论内容