docker-springboot项目发布
2021/4/29 10:29:48
本文主要是介绍docker-springboot项目发布,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
springboot(jar包发布):
docker build -t water-data-sync-ys .
docker run -d --name=water-data-sync-ys -p 8827:8827 water-data-sync-ys
tomcat发布:
镜像拉取:
docker pull tomcat:latest
启动:
外部项目地址:/software/docker-tomcat/dorun-yl/
外部日志地址:/software/docker-tomcat/logs/dorun-yl/
docker run --name=tomcat-yl -d -p 8082:8080 -v /software/docker-tomcat/dorun-yl/:/usr/local/tomcat/webapps/ -v /software/docker-tomcat/logs/dorun-yl/:/home/logs/ tomcat
tomcat查看日志:
docker logs -f --tail=200 tomcat-yl
解决tomcat时间差8小时:
方法1(没解决):
docker run --name=tomcat-yl -d -p 8082:8080 -v /software/docker-tomcat/dorun-yl/:/usr/local/tomcat/webapps/ -v /software/docker-tomcat/logs/dorun-yl/:/home/logs/ -v /etc/localtime:/etc/localtime:ro tomcat
方法2(没解决):
docker cp /usr/share/zoneinfo/Asia/Shanghai tomcat-yl:/etc/localtime
方法3(已解决):
进入容器:
docker exec -it tomcat-yl /bin/bash
容器内执行:
echo "Asia/Shanghai" > /etc/timezone
退出容器:
exit
shell脚本处理:
目录/software/docker-tomcat/dorun-yl 发布springboot目录的jar包,做classes和jar包的交换发布:
#!/bin/bash
yl_path=/software/docker-tomcat/dorun-yl
if [ ! -d "${yl_path}/admin-sync" ];then
mkdir -p ${yl_path}/admin-sync
echo waiting add admin-sync
else
rm -rf ${yl_path}/admin-sync/*
echo waiting remove admin-sync children
fi
rm -rf ${yl_path}/admin/WEB-INF/classes/com ${yl_path}/admin/WEB-INF/lib
echo waiting remove classs
unzip ${yl_path}/admin.jar -d ${yl_path}/admin-sync > /dev/null 2>&1
echo waiting unzip admin.jar sleep 5s
sleep 5
cp -r ${yl_path}/admin-sync/BOOT-INF/classes/com ${yl_path}/admin/WEB-INF/classes
cp -r ${yl_path}/admin-sync/BOOT-INF/lib ${yl_path}/admin/WEB-INF
echo waiting copy class sleep 5s
sleep 5
rm -rf ${yl_path}/admin-sync
echo waiting remove admin-sync
docker restart tomcat-yl>/dev/null 2>&1&
echo tomcat-yl server start.
这篇关于docker-springboot项目发布的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-25Java创意资料:新手入门的创意学习指南
- 2024-11-25JAVA对接阿里云智能语音服务资料详解:新手入门指南
- 2024-11-25Java对接阿里云智能语音服务资料详解
- 2024-11-25Java对接阿里云智能语音服务资料详解
- 2024-11-25JAVA副业资料:新手入门及初级提升指南
- 2024-11-25Java副业资料:入门到实践的全面指南
- 2024-11-25Springboot应用的多环境打包项目实战
- 2024-11-25SpringBoot应用的生产发布项目实战入门教程
- 2024-11-25Viite多环境配置项目实战:新手入门教程
- 2024-11-25Vite多环境配置项目实战入门教程