Dockerfile文件
FROM 192.168.1.127:5000/jdk:11
MAINTAINER tfinfoADD andon-basic.jar /andon-basic.jarENTRYPOINT ["java","-XX:+UseG1GC","-XX:+TieredCompilation","-Dspring.profiles.active=dev","-Dserver.addr=192.168.1.153:8848","-jar","/andon-basic.jar"]
#启动方法
start(){docker build -t andon-basic-dev:latest .docker run -d --name=andon-basic-dev --network=host -v /usr/local/logs:/usr/local/logs andon-basic-dev:latest /bin/bash
}
#停止方法
stop(){docker stop andon-basic-devdocker rm andon-basic-devdocker rmi andon-basic-dev
}#重启
restart(){stopsleep 4start
}
启动相关脚本
#!/bin/bash
APP_NAME=andon-basic
ENV=dev
TIME=$(date "+%Y-%m-%d")#启动方法
start(){docker build -t ${APP_NAME}-${ENV}:latest .docker run -d --name=${APP_NAME}-${ENV} --network=host -v /usr/local/logs:/usr/local/logs ${APP_NAME}-${ENV}:latest /bin/bashtail -100f /usr/local/logs/andon-basic-log/andon-basic.${TIME}.0.log
}nologstart(){docker build -t ${APP_NAME}-${ENV}:latest .docker run -d --name=${APP_NAME}-${ENV} --network=host -v /usr/local/logs:/usr/local/logs ${APP_NAME}-${ENV}:latest /bin/bash
}#停止方法
stop(){docker stop ${APP_NAME}-${ENV}docker rm ${APP_NAME}-${ENV}docker rmi ${APP_NAME}-${ENV}
}#重启
restart(){stopsleep 4start
}jenkins(){stopsleep 4nologstart
}#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in"start")start;;"stop")stop;;"jenkins")jenkins;;*)restart;;
esac