将 EurekaServer 部署在 docker 中
作者:互联网
EurekaServer
配置文件
server:
port: ${EUREKA_PORT:8761}
eureka:
instance:
hostname: ${HOSTNAME:localhost}
appname: eureka-server
ip-address: ${EUREKA_IP:127.0.0.1}
instance-id: ${eureka.instance.hostname}:${eureka.instance.appname}:${server.port}
prefer-ip-address: true
client:
service-url:
default-zone: http://${eureka.instance.ip-address}:${server.port}/eureka/
Dockerfile
FROM openjdk:11
WORKDIR /root/app/eureka-server
ENV EUREKA_IP=127.0.0.1 EUREKA_PORT=8761
COPY eureka-server-0.0.1-SNAPSHOT.jar eureka-server-1.0.jar
CMD ["java", "-jar", "eureka-server-1.0.jar"]
EXPOSE 8761
构建
首先将 eureka-servere 程序打包, 并将 jar 包放到 Dockerfile 同级目录下
接下来在 Dockerfile 所在目录执行 docker 构建命令
docker build -t eureka-server:1.0 .
运行
在基于 WSL2 的 Docker Desktop 中运行 eureka-server, 这里的 IP 可以使用 127.0.1.1
docker run -itd --name=eureka-server -p 8761:8761 -e EUREKA_IP=127.0.1.1 eureka-server:1.0
标签:EUREKA,部署,jar,server,instance,EurekaServer,8761,docker,eureka 来源: https://www.cnblogs.com/xtyuns/p/15593402.html