docker 手动安装部署jar包
创建Dockerfile 文件
例:
FROM jdk:11
MAINTAINER tfinfo
ADD ems-basic.jar /ems-gb.jar
ENTRYPOINT ["java","-XX:+UseG1GC","-XX:+TieredCompilation","-Dspring.profiles.active=gb-dev-mysql","-Dspring.group=EMS_GB_GROUP","-Dserver.addr=192.168.1.127:8848","-jar","/ems-gb.jar"]
创建脚本
#!/bin/bash
APP_NAME=ems-gb-mysql
ENV=dev
TIME=$(date "+%Y-%m-%d")
#启动方法
start(){
sudo docker build -t ${APP_NAME}-${ENV}:latest .
sudo docker run -d --restart=always --name=${APP_NAME}-${ENV} --network=host -v /usr/local/logs:/usr/local/logs ${APP_NAME}-${ENV}:latest /bin/bash
sudo tail -100f /usr/local/logs/${APP_NAME}-log/${APP_NAME}.${TIME}.0.log
}
#停止方法
stop(){
sudo docker stop ${APP_NAME}-${ENV}
sudo docker rm ${APP_NAME}-${ENV}
sudo docker rmi ${APP_NAME}-${ENV}
}
#重启
restart(){
stop
sleep 4
start
}
#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"start")
start
;;
"stop")
stop
;;
*)
restart
;;
esac