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.

上一篇:Winform混合式开发框架访问Web API接口的处理


下一篇:Http下的各种操作类.WebApi系列~通过HttpClient来调用Web Api接口