续上一篇
1. 修改java工程的pom.xml , 加入docker编译插件
<plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.0.0</version> <configuration> <imageName>camus</imageName> <dockerDirectory>docker</dockerDirectory> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> 说明: imageName 镜像名称 dockerDirectory Dockerfile所在的目录
2. 编写Dockerfile,放到docker目录下面
docker目录在
FROM docker.io/fabric8/java-alpine-openjdk8-jdk MAINTAINER "camus"<27447985@qq.com> ENV AB_OFF true EXPOSE 8001 ADD hello-1.00.jar hello.jar CMD java -jar hello.jar
3. 编译镜像
mvn clean package docker:build
4. 查看镜像
docker images
5. 运行镜像
docker run -d -p8001:8001 camus 远程访问: http://ip地址:8001/ 出现helloword表示成功生成了镜像原文链接:https://www.f2er.com/centos/375514.html