Jenkins+docker+springboot 构建自动部署容器
1、构建-执行shell
cd /root/.jenkins/workspace/kjs-v2-prod/kjs-imessage/kjs-message-webapp docker images xxx.aliyuncs.com/kjs-v2-prod/kjs-imessage #构建镜像 docker build -t xxx.aliyuncs.com/kjs-v2-prod/kjs-imessage . #查看构建是否成功 docker images xxx.aliyuncs.com/kjs-v2-prod/kjs-imessage #git --version sudo docker login --username=xxx --password=xxx xxx.aliyuncs.com docker push xxx.aliyuncs.com/kjs-v2-prod/kjs-imessage docker images #强制删除镜像 docker rmi $(docker images xxx.aliyuncs.com/kjs-v2-prod/kjs-imessage -q) -f --force
2、构建-Execute shell script on remote host using ssh
#https://blog.csdn.net/zimou5581/article/details/94012682 #查看本地所有镜像 docker images #查看本地所有容器 docker ps -a #停止容器 docker stop `docker ps -aq --filter name=kjs-imessage` #删除容器 docker rm `docker ps -aq --filter name=kjs-imessage` #删除本地镜像 docker rmi $(docker images xxx.aliyuncs.com/kjs-v2-prod/kjs-imessage -q) -f --force #登录镜像服务器 sudo docker login --username=xx --password=xxx xxx.aliyuncs.com #拉取镜像 docker pull xxx.aliyuncs.com/kjs-v2-prod/kjs-imessage #创建容器 docker run --restart=always -p 9094:8080 -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime -v /usr/tools/tomcat/logs/kjs-imessage:/usr/local/tomcat/logs --name kjs-imessage -d xxx.aliyuncs.com/kjs-v2-prod/kjs-imessage #查看日志 docker logs `docker ps -aq --filter name=kjs-imessage` #查看容器 docker ps -a --filter name=kjs-imessage #检查是否部署成功 curl https://xxxxx/imessage/
精确查找:docker ps -aq --filter name=^/kjs-imessage$