vi /lib/systemd/system/docker.service
修改配置
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
二、Maven配置三、测试项目harbor-regisry admin Harbor12345 admin@example.com
项目结构
EurekaserverApplication
package com.example.eurekaserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class EurekaserverApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaserverApplication.class, args);
}
}
Dockerfile
#定制的镜像基于java(这里java是jdk镜像,latest的版本)镜像 FROM harbor.register/jdk/jdk1.8:v1 #指定镜像创建者信息 MAINTAINER zhuzq #其效果是在主机 /var/lib/docker 目录下创建了一个临时文件,并链接到容器的 /tmp VOLUME /tmp #把eurekaserver.jar 拷贝到容器eurekaserver.jar ADD eurekaserver.jar eurekaserver.jar #在容器启动程序 ENTRYPOINT ["java","-jar","/eurekaserver.jar"]
application.yaml
server:
port: 8000
eureka:
instance:
hostname: localhost # 指定Eureka主机
client:
register-with-eureka: false # 指定当前主机是否向Eureka服务器进行注册
fetch-registry: false # 指定当前主机是否要从Eurka服务器下载服务注册列表
service-url: # 服务暴露地址
defaultZone: http://localhost:8000/eureka
# defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka
# server:
# enable-self-preservation: false # 关闭自我保护
pom.xml
四、测试4.0.0 com.example eurekaserverv1 jar org.springframework.boot spring-boot-starter-parent2.1.7.RELEASE 1.8 Greenwich.SR1 org.springframework.cloud spring-cloud-starter-netflix-eureka-serverorg.springframework.boot spring-boot-autoconfigureorg.springframework.cloud spring-cloud-dependencies${spring-cloud.version} pom import eurekaserver org.springframework.boot spring-boot-maven-plugincom.spotify docker-maven-plugin1.0.0 harbor.register/eurekaserver/${project.artifactId}:${project.version} ${project.basedir}/src/main/resources/docker harbor.register/jdk/jdk1.8:v1 true harbor-regisry https://harbor.register/ / ${project.build.directory} ${project.build.finalName}.jar http://harbor.register:2375
maven-lifecycle-package
maven-plugings-docker
harbor服务器
harbor私服仓库



