<artifactId>xxx-docker</artifactId> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <docker.image.prefix>registry-vpc.cn-qingdao.aliyuncs.com/xxx</docker.image.prefix> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <!-- Docker maven plugin --> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.0.0</version> <configuration> <imageName>${docker.image.prefix}/${project.artifactId}</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> </plugins> </build>
FROM frolvlad/alpine-oraclejdk8:slim VOLUME /tmp ADD xxx-docker-1.0.0.RELEASE.jar app.jar ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
請參考:http://www.javashuo.com/article/p-yeukvsgk-dx.htmljava
jenkins的服務器須要安裝dockerweb
在須要啓動項目的服務器啓動,該服務器須要安裝docker。redis
docker pull registry.cn-qingdao.aliyuncs.com/xxx/xxx-docker
docker run -d -p 8082:8082 registry-vpc.cn-qingdao.aliyuncs.com/xxx/xxx-docker
docker stop registry-vpc.cn-qingdao.aliyuncs.com/xxx/xxx-docker
docker logs -f 7a38a1ad55c6