• docker-打包发布脚本


    思路:直接将jar包放到某个文件夹,通过脚本实现打包image,并发布

    #目录下文件显示jar包、Dockerfile文件、打包启动脚本
    [root@localhost mkpackge1]# ls
    chinapopin-department-web-1.0-SNAPSHOT.jar  Dockerfile  qd.sh
    
    #启动脚本内容
    [root@localhost mkpackge1]# more qd.sh 
    #!/bin/bash
    dir=$(cd $(dirname $0);pwd)
    i=${1-image_name}
    #delete pod
    docker rm -f $i
    #delete image
    docker rmi -f $i:latest
    #makpage
    cd $dir
    docker build -t $i:latest .
    #start pod
    docker run --name $i --net=host -d $i:latest
    
    #Dockerfile内容---注意需要修改jar的端口7002改成直接程序的
    [root@localhost mkpackge1]# more Dockerfile 
    FROM wukc/openjdk:8-jdk-alpine
    COPY *.jar app.jar
    EXPOSE 7002
    ENTRYPOINT ["java","-jar","/app.jar"]
    

      

    启动方式sh qd.sh deploy_name

    [root@localhost mkpackge1]# sh qd.sh department-web
    Error: No such container: department-web
    Error: No such image: department-web:latest
    Sending build context to Docker daemon  62.88MB
    Step 1/4 : FROM wukc/openjdk:8-jdk-alpine
     ---> a3562aa0b991
    Step 2/4 : COPY *.jar app.jar
     ---> 78df7f8f3236
    Step 3/4 : EXPOSE 7002
     ---> Running in 282b3ebea0a9
    Removing intermediate container 282b3ebea0a9
     ---> c7f08cf6df7c
    Step 4/4 : ENTRYPOINT ["java","-jar","/app.jar"]
     ---> Running in 4f3fffde2313
    Removing intermediate container 4f3fffde2313
     ---> ca0b0823f20f
    Successfully built ca0b0823f20f
    Successfully tagged department-web:latest
    7121af112baf6fc8cd8376fcd0e56c337f76f1e29bd772b67dfa81ad54c9de67
    
    #结果查看
    [root@localhost mkpackge1]# docker images
    REPOSITORY       TAG            IMAGE ID       CREATED         SIZE
    department-web   latest         ca0b0823f20f   3 seconds ago   168MB
    wukc/openjdk     8-jdk-alpine   a3562aa0b991   2 years ago     105MB
    
    [root@localhost mkpackge1]# docker ps -a
    CONTAINER ID   IMAGE                   COMMAND                  CREATED         STATUS         PORTS                    NAMES
    7121af112baf   department-web:latest   "java -jar /app.jar"     6 seconds ago   Up 6 seconds                            department-web
    

      

      

    做一个决定,并不难,难的是付诸行动,并且坚持到底。
  • 相关阅读:
    IOS8 设置TableView Separatorinset 分割线从边框顶端开始
    文件目录的访问
    The file “XXX” couldn’t be opened because you don’t have permission to view it.解决方法:
    NSString 的常见方法
    如何在一个工作站里创建多个工程(同一个xcode下面创建多个工程)
    自定义NSLog
    内存恶鬼drawRect
    URL编码解码
    怎样在UICollectionView中添加Header和footer
    本人开始玩微信公众号了!名称:BHS编程技术交流分享,只发干货,不发水文,欢迎阅读
  • 原文地址:https://www.cnblogs.com/wukc/p/15502878.html
Copyright © 2020-2023  润新知