cat startecs.sh 启动一个容器
#!/bin/bash
if [ $# -eq 4 ];
then
echo "container name: $1"
echo "image: $2"
echo "image tag: $3"
echo "container port:$4"
else
echo "example://sh $0 mycontainer centos 7 5001 "
exit
fi
#demon="/usr/sbin/init"
demon="/bin/bash"
#-t 选项让Docker分配一个伪终端(pseudo-tty)并绑定到容器的标准输入上, -i 则让容器的标准输入保持打开。
EXEC="docker run -d -t -i -p $4:22 --platform linux/amd64 --name $1 --privileged=true $2:$3 $demon"
echo $EXEC
$EXEC
cat delecs.sh 删除一个容器
#!/bin/bash
if [ $# -eq 1 ];
then
echo "container name: $1"
else
echo "example://sh $0 mycontainer"
exit
fi
docker stop $1
docker rm $1
cat inecs.sh 进入一个容器
#!/bin/bash
if [ $# -eq 1 ];
then
echo "container name: $1"
else
echo "example://sh $0 mycontainer "
exit
fi
docker exec -it $1 /bin/bash