SpringBoot Docker远程发布
docker远程发布有2种方法一种是直接利用mevan的docker插件配置发布参数,另一种是使用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> <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
-
-
方式二: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位置
- maven命令发布:
clean package docker:build
-