Jenkins-docker-svn 自动化部署 2018-1
下面奉上脚本image_version=`date +%Y%m%d%H%M`;
docker tag yourself/spring-boot-demo:latest yourself/spring-boot-demo:$image_version
mvn clean package docker:build
if docker ps | grep -i sbdemo; then
docker stop sbdemo
fi
if docker ps -a | grep -i sbdemo; then
docker rm sbdemo
fi
docker run --name sbdemo -v /home/yourself:/logs -dit -p 8004:8004 yourself/spring-boot-demo
推送镜像脚本
docker tag yourself/spring-boot-demo ip:5000/yourself/spring-boot-demodocker push ip:5000/yourself/spring-boot-demo
curl ip:5000/v2/_catalog
拉取并运行镜像
if docker ps | grep -i sbdemo ; then
docker stop sbdemo
fi
if docker ps -a | grep -i sbdemo ; then
docker rm sbdemo
fi
if docker images | grep -i ip:5000/yourself/spring-boot-demo ; then
docker rmi ip:5000/yourself/spring-boot-demo
fi
docker pull ip:5000/yourself/spring-boot-demo
docker run --name sbdemo -v /home/yourself:/logs -dit -p 8004:8004 ip:5000/yourself/spring-boot-demo