docker启动 Dockerfile

Dockerfile文件

FROM 192.168.1.127:5000/jdk:11
MAINTAINER tfinfo

ADD andon-basic.jar /andon-basic.jar

ENTRYPOINT ["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-dev
  docker rm andon-basic-dev
  docker rmi andon-basic-dev
}

#重启
restart(){
  stop
  sleep 4
  start
}





启动相关脚本

#!/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/bash
  tail -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(){
  stop
  sleep 4
  start
}

jenkins(){
 stop
 sleep 4
 nologstart
}
 
#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
  "start")
    start
    ;;
  "stop")
    stop
    ;;
  "jenkins")
    jenkins
    ;;
  *)
    restart
    ;;
esac
































 

你可能感兴趣的:(docker,容器,运维)