1.启动脚本:
以apline镜像进入sh为例,启动命令:sh start.sh 10
#! /bin/bash
COUNT=$1
if [ -z "$COUNT" ];then
echo "please input the number of container"
exit 1
fi
while [ "$COUNT" -gt 0 ];do
docker run -d -ti --rm --name alpine-"$COUNT" alpine sh
COUNT=$(($COUNT-1))
done
2.停止脚本:
docker container ls --format "{{.ID}}:{{.Image}}:{{.Names}}" | awk 'BEGIN {FS=":"}{print $3}' | xargs docker rm -f
网友评论