我对docker,Spring框架的一切都很陌生…它们成功地在localhost环境中运行,现在我想把它们推送到docker中,但是总是给我错误,我在那里卡住了大约一周。有人能帮我弄清楚吗!!!
现在我有 eureka 服务器和云配置服务器服务,这是我的代码:
尤里卡服务器应用程序.yml
server:
port: 8761
spring:
application:
name: service-registration
eureka:
client:
register-with-eureka: false
fetch-registry: false
management:
security:
enabled: false
和 Dockerfile:
FROM openjdk:11
COPY target/service-registration-0.0.1-SNAPSHOT.jar service-registration.jar
EXPOSE 8761
CMD ["java", "-jar", "service-registration.jar"]
现在我有云配置服务器应用程序.yml:在这个文件中,我试图在github上备份它。从一开始,我就尝试将主机名更改为本地主机或任何其他主机名,如服务注册、尤里卡服务器等......但不是工作,并且“服务网址”或“服务网址”....
server:
port: 9291
spring:
application:
name: cloud-config-server
profiles:
active: production
# cloud:
# config:
# server:
# git:
# uri: https://github.com/sshaunn/config-server
# clone-on-start: true
eureka:
client:
register-with-eureka: true
fetch-registry: true
serviceUrl:
defaultZone: http://service-registration:8761/eureka/
instance:
# prefer-ip-address: true
# ip-address: http://eureka-server:8761/eureka/å
hostname: service-registration
Dockerfile:
FROM openjdk:11
COPY target/cloud-config-server-0.0.1-SNAPSHOT.jar cloud-config-server.jar
EXPOSE 9291
ENTRYPOINT ["java", "-jar", "cloud-config-server.jar"]
和 docker-compose.yml 文件:
version: '3.7'
services:
service-registration:
image: service-registration
networks:
- eureka-server
ports:
- "8761:8761"
container_name: service-registration
hostname: service-registration
cloud-config-server:
build: cloud-config-server
networks:
- eureka-server
ports:
- "9291:9291"
depends_on:
- service-registration
container_name: cloud-config-server
hostname: service-registration
environment:
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://service-registration:8761/eureka
networks:
eureka-server:
name: eureka-server
driver: bridge
# route:
# image: route
# ports:
# - "9191:9191"
# container_name: api-gateway
# environment:
# EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://service-registration:8761/eureka
2022-05-29 07:22:41.713 WARN 1-[freshxecutor-0]c . n . d . s . t . d . retryableurekahttpclient:请求执行失败,出现消息:对“http://localhost:8761/eureka/apps/”的GET请求出现I/O错误:连接到localhost:8761[localhost/127 . 0 . 0 . 1]失败:连接被拒绝(连接被拒绝);2022-05-29 07:06:11.565 WARN 1-[tbeat executor-0]c . n . d . s . t . d . retryableurekahttpclient:请求执行失败,出现消息:对“http://localhost:8761/eureka/apps/CONFIG-SERVER/service-registration:CONFIG-SERVER:9291”的PUT请求出现I/O错误:连接到localhost:8761[localhost/127 . 0 . 0 . 1]
您应该使用您的主机ip地址在您的本地机器上运行。对于docker,它不应该是< code>localhost
请尝试在您的< code > application . properties 文件中使用以下配置。
eureka.client.service-url.defaultZone=http://host.docker.internal:8761/eureka/
好吧,我不知道为什么,但我建立了一个docker-compose.yml文件,它是这样的:注意,我在docker-compose.yml文件中设置了关于“服务URL”default zone的环境。
version: '3.7'
services:
service-registration:
container_name: service-registration
build:
context: ./service-registration
dockerfile: Dockerfile
ports:
- "8761:8761"
cloud-config-server:
container_name: cloud-config-server
build:
context: ./cloud-config-server
dockerfile: Dockerfile
environment:
- eureka.client.service-url.defaultZone=http://service-registration:8761/eureka
depends_on:
- service-registration
ports:
- "9191:9191"
route:
container_name: route
build:
context: ./route
dockerfile: Dockerfile
environment:
- eureka.client.service-url.defaultZone=http://service-registration:8761/eureka
depends_on:
- service-registration
- employee
- income
ports:
- "9291:9291"
employee:
container_name: employee
build:
context: ./employee
dockerfile: Dockerfile
environment:
- eureka.client.service-url.defaultZone=http://service-registration:8761/eureka
depends_on:
- service-registration
ports:
- "9001:9001"
income:
container_name: income
build:
context: ./income
dockerfile: Dockerfile
environment:
- eureka.client.service-url.defaultZone=http://service-registration:8761/eureka
depends_on:
- service-registration
ports:
- "9002:9002"
pom.xml 主应用程序类 Application.Properties eureka客户端设置 pom.xml Application.Properties 我在eureka-server仪表板(http://localhost:8761)中没有看到向Eureka server注册的micro-service-currency-exchange-service 为什么eureka客户端没有注册
我刚刚关注了下面这篇文章,https://spring.io/blog/2015/07/14/microservices-with-spring,但是我无法在尤里卡注册我的微服务。 customer-service.yml build . gradle for customer-service CustomerService.java 注册-server.yml
我能够让eureka服务器以点对点模式运行。但我很好奇的一件事是如何让服务发现客户端注册到多个eureka服务器。 我的用例如下:<br>假设我有一个服务注册到其中一个eureka服务器(例如服务器a),并且该注册被复制到它的对等服务器。服务实际上指向服务器A。如果服务器A停机,客户机希望与服务器A续费,如果服务器A不再存在,续费如何工作。我是否需要同时向这两个服务器注册?如果不是,那么如果客户端
我想在Spring启动的eureka服务器上注册Grails 2.4.4中的eureka客户端。 我已经在同一台eureka服务器上从spring boot注册了另一个eureka服务,它运行良好。当我运行grails应用程序时,它会给我一个错误: 这是我的申请表。属性文件: 任何帮助都是值得的。 谢谢