SpringBoot Docker远程发布

wsyjlly 2019-08-13

java docker 配置 Maven 插件 plugin

SpringBoot Docker远程发布

docker远程发布有2种方法一种是直接利用mevan的docker插件配置发布参数,另一种是使用Dockerfile文件发布

  1. 方式一:插件配置发布

    • maven配置

      <plugin>
          <groupId>com.spotify</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>1.0.0</version>
          <configuration>
              <dockerHost>http://***.***.***.***:2375</dockerHost>
              <imageName>${project.name}:${project.version}</imageName>
              <workdir>/ysw/app</workdir>
              <volumes>/ysw/app</volumes>
              <baseImage>java:8</baseImage>
              <entryPoint>["java", "-jar", "/ysw/app/${project.build.finalName}.jar"]</entryPoint>
              <resources>
                  <resource>
                      <targetPath>/</targetPath>
                      <directory>${project.build.directory}</directory>
                      <include>${project.build.finalName}.jar</include>
                  </resource>
              </resources>
          </configuration>
      </plugin>
    • maven命令发布:clean package docker:build
      1563257611814
  2. 方式二:Dockerfile构建

    • maven插件配置

      <plugin>
          <groupId>com.spotify</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>1.0.0</version>
          <configuration>
              <dockerHost>http://***.***.***.***:2375</dockerHost>
              <imageName>${project.name}:${project.version}</imageName>
              <dockerDirectory>src/main/docker</dockerDirectory>
              <resources>
                  <resource>
                      <targetPath>/</targetPath>
                      <directory>${project.build.directory}</directory>
                      <include>${project.build.finalName}.jar</include>
                  </resource>
              </resources>
          </configuration>
      </plugin>
    • Dockerfile内容

      FROM         java:8
      #FROM        tomcat:8
      # 环境变量
      ENV APP     app-0.0.1-SNAPSHOT.jar
      
      WORKDIR     /ysw/app
      VOLUME         /ysw/app
      ADD            $APP /ysw/app/app.jar
      ENTRYPOINT     ["java", "-jar", "/ysw/app/app.jar"]
      EXPOSE         8080
    • Dockerfile位置
      1563257520848
    • maven命令发布:clean package docker:build
      1563257611814
登录 后评论
下一篇
冒顿单于
9410人浏览
2019-08-28
相关推荐
SpringBoot企业级框架
797人浏览
2016-12-17 21:32:00
JAVA项目发布到docker
543人浏览
2019-03-23 17:03:04
idea使用docker插件
998人浏览
2018-08-30 10:53:00
0
0
0
184