标签:resource doc code file 插件 image div config getpath
1.新建一个最简单的springboot项目
https://code.aliyun.com/859143303/hello-world.git
2.src/main/docker下新建Dockerfile:
FROM openjdk:8
MAINTAINER xc
ADD docker-hello-world-0.0.1-SNAPSHOT.jar /app/my-docker-hello-world.jar
CMD ["java", "-Xmx200m", "-jar", "/app/my-docker-hello-world.jar"]
EXPOSE 6083
3.pom.xml中增加docker-maven-plugin:
<!--在build的 plugins中添加 Docker构建插件 -->
<!-- Docker maven plugin -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>192.168.199.100:5000/docker-hello-world</imageName>
<!--<imageName>${docker.image.prefix}/${project.artifactId}</imageName>-->
<dockerDirectory>src/main/docker</dockerDirectory>
<dockerHost>http://192.168.199.100:2375</dockerHost>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<!-- Docker maven plugin -->
4.mvn clean package
5.构建镜像
6.连接到服务器上,启动
docker run --name my-docker-hello -p 6083:6083 -d 192.168.199.100:5000/docker-hello-world
7.访问:
http://192.168.199.100:6083/
标签:resource doc code file 插件 image div config getpath
原文地址:https://www.cnblogs.com/ooo0/p/11829547.html