docker指南系列之部署springboot项目

版本信息

docker版本信息

Client:
 Version:         1.13.1
 API version:     1.26
 Package version: docker-1.13.1-103.git7f2769b.el7.centos.x86_64
 Go version:      go1.10.3
 Git commit:      7f2769b/1.13.1
 Built:           Sun Sep 15 14:06:47 2019
 OS/Arch:         linux/amd64

Server:
 Version:         1.13.1
 API version:     1.26 (minimum version 1.12)
 Package version: docker-1.13.1-103.git7f2769b.el7.centos.x86_64
 Go version:      go1.10.3
 Git commit:      7f2769b/1.13.1
 Built:           Sun Sep 15 14:06:47 2019
 OS/Arch:         linux/amd64
 Experimental:    false

maven docker plugin 版本信息


    
        
            com.spotify
            dockerfile-maven-plugin
            0.4.13
        
    


项目相关信息

创建Dockerfile文件

目录结构如下:

Docker内容如下:

FROM java:8
ADD ./docker-0.0.1.jar  ./app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "./app.jar"]

项目pom.xml文件信息

pom.xml文件基本内容:


    4.0.0

    com.yee
    docker
    0.0.1
    jar

    docker
    Demo project for Spring Boot

    
        org.springframework.boot
        spring-boot-starter-parent
        2.0.6.RELEASE
         
    

    
        UTF-8
        UTF-8
        1.8
        XXXX
    

    
        
            org.springframework.boot
            spring-boot-starter
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            org.springframework.boot
            spring-boot-starter-web
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    com.yee.docker.DockerApplication
                
                
                    
                        
                            repackage
                        
                    
                
            
        
    

在pom文件中添加docker-plugin相关信息:

此方式依赖Dockerfile


  com.spotify
  docker-maven-plugin
  0.4.13
  
    ${project.build.finalName}
    ./
    
      
        /
        ${project.build.directory}
        ${project.build.finalName}.jar
      
    
  
  
    
      install
      
        build
      
    
    
      tag-image
      install
      
        tag
      
      
        ${project.build.finalName}
        ${repository.url}/${project.build.finalName}
      
    
    
      push-image
      install
      
        push
      
      
        ${repository.url}/${project.build.finalName}
      
    
    
      push-image
      install
      
        push
      
      
        ${docker.repository}/${project.build.finalName}
      
    
  

在pom文件中配置Dockerfile相关信息(即可以不配置之前提到的Dockerfile):

此方式不依赖Dockerfile


    com.spotify
    docker-maven-plugin
    0.4.13
    
        ${project.build.finalName}
        ./
        java:8
        ["java", "-version"]
        ["java", "-jar", "${project.build.finalName}.jar"]
        
            
                /
                ${project.build.directory}
                ${project.build.finalName}.jar
            
        
    
    
        
            install
            
                build
            
        
        
            tag-image
            install
            
                tag
            
            
                ${project.build.finalName}
                ${repository.url}/${project.build.finalName}
            
        
        
            push-image
            install
            
                push
            
            
                ${repository.url}/${project.build.finalName}
            
        
    

创建镜像

你可能感兴趣的:(docker指南系列之部署springboot项目)