<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/</outputDirectory>
<resources>
<resource>
<directory>.docker</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
FROM java:8u111-jdk
ADD spring-boot-maven-docker.jar /opt/spring-boot-maven-docker/
EXPOSE 8080
WORKDIR /opt/spring-boot-maven-docker/
CMD ["java", "-jar", "spring-boot-maven-docker.jar"]
- 生成镜像文件
- Dockerfile和jar包放在同一个目录下
- docker build -t spring-boot .
- 生成容器并启动
- docker run -itd -p 8090:8090 --name spring 1f7b9450a802
- 详细地址