registry私人镜像仓库:

docker pull hub.c.163.com/library/registry:latest

Docker tag imageid registry

docker run -d -p 5000:5000 -v /Users/zhongxing/docker/registry/opt:/var/lib/registry registry

pom.xml: 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<artifactId>base-eureka</artifactId>
	<packaging>jar</packaging>

	<name>base-eureka</name>
	<description>Demo project for Spring Boot</description>

	<parent>
		<groupId>com.zxing</groupId>
		<artifactId>base-ms</artifactId>
		<version>1.0-SNAPSHOT</version>
	</parent>

	<properties>
		<docker.registry>192.168.20.200:5000</docker.registry>
		<push.image>true</push.image>
	</properties>

	<dependencies>

		<dependency>
			<groupId>net.logstash.logback</groupId>
			<artifactId>logstash-logback-encoder</artifactId>
			<version>4.10</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
		</dependency>

	</dependencies>

	<build>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
			<resource>
				<directory>${env}</directory>
				<filtering>true</filtering>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>com.spotify</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<version>0.4.13</version>
				<configuration>
					<imageName>${docker.registry}/${project.groupId}/${project.artifactId}:${project.version}</imageName>
					<dockerDirectory>${basedir}/src/main/docker</dockerDirectory>
					<pushImage>${push.image}</pushImage>
					<resources>
						<resource>
							<directory>${project.build.directory}</directory>
							<include>${project.build.finalName}.jar</include>
						</resource>
					</resources>
				</configuration>
			</plugin>
		</plugins>
	</build>


</project>

Dockerfile:

FROM java:8
ADD base-eureka-1.0-SNAPSHOT.jar app.jar
CMD ["java","-jar","app.jar"]

mac 配置insecure registries: (docker push fail。。。)

maven运行:

docker:build

打包结果:

运行:

docker run -d -p 8761:8761 --name=eureka 192.168.20.200:5000/com.zxing/base-eureka:1.0-SNAPSHOT

https://blog.csdn.net/boling_cavalry/article/details/78872020

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐