【问题标题】:Deploy Spring Eureka Service Registry on Azure with docker image使用 docker 镜像在 Azure 上部署 Spring Eureka Service Registry
【发布时间】:2019-11-13 11:53:16
【问题描述】:

我创建了一个 Docker 映像并通过 docker hub 加载它。然后尝试将其作为 docker 容器运行并暴露端口 8080。列出了容器,端口列显示如下:0.0.0.0:8080->8080/tcp。

所以我认为该服务正在运行,但我无法使用 ip-addres/eureka 访问它。

如何打开 Eureka 仪表板?

编辑: 我更改了端口,现在容器的端口列显示:0.0.0.0:8761->8761/tcp

这是日志:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.5.RELEASE)

2019-07-03 12:04:04.714  INFO 1 --- [           main] d.h.d.DiscoveryServiceApplication        : No active profile set, falling back to default profiles: default
2019-07-03 12:04:06.481  WARN 1 --- [           main] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2019-07-03 12:04:07.232  INFO 1 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=ce95a042-2fd4-339b-a733-0cc54c83f3f1
2019-07-03 12:04:07.484  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$f3fe9d60] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-07-03 12:04:08.092  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8761 (http)
2019-07-03 12:04:08.166  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-07-03 12:04:08.170  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.19]
2019-07-03 12:04:08.352  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-07-03 12:04:08.352  INFO 1 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3607 ms
2019-07-03 12:04:08.606  WARN 1 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-07-03 12:04:08.620  INFO 1 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-07-03 12:04:08.669  INFO 1 --- [           main] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@1863d2fe
2019-07-03 12:04:10.133  INFO 1 --- [           main] c.s.j.s.i.a.WebApplicationImpl           : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2019-07-03 12:04:10.331  INFO 1 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-07-03 12:04:10.338  INFO 1 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-07-03 12:04:10.685  INFO 1 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-07-03 12:04:10.694  INFO 1 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-07-03 12:04:11.443  WARN 1 --- [           main] o.s.c.n.a.ArchaiusAutoConfiguration      : No spring.application.name found, defaulting to 'application'
2019-07-03 12:04:11.445  WARN 1 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-07-03 12:04:11.445  INFO 1 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-07-03 12:04:11.843  INFO 1 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-07-03 12:04:12.932  INFO 1 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2019-07-03 12:04:13.018  INFO 1 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2019-07-03 12:04:13.018  INFO 1 --- [           main] com.netflix.discovery.DiscoveryClient    : Client configured to neither register nor query for data.
2019-07-03 12:04:13.041  INFO 1 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1562155453040 with initial instances count: 0
2019-07-03 12:04:13.162  INFO 1 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initializing ...
2019-07-03 12:04:13.169  INFO 1 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Adding new peer nodes [http://localhost:8761/eureka/]
2019-07-03 12:04:13.569  INFO 1 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-07-03 12:04:13.570  INFO 1 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-07-03 12:04:13.571  INFO 1 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-07-03 12:04:13.571  INFO 1 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-07-03 12:04:13.841  INFO 1 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Replica node URL:  http://localhost:8761/eureka/
2019-07-03 12:04:13.859  INFO 1 --- [           main] c.n.e.registry.AbstractInstanceRegistry  : Finished initializing remote region registries. All known remote regions: []
2019-07-03 12:04:13.860  INFO 1 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initialized
2019-07-03 12:04:13.890  INFO 1 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-07-03 12:04:14.103  INFO 1 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application unknown with eureka with status UP
2019-07-03 12:04:14.123  INFO 1 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : Setting the eureka configuration..
2019-07-03 12:04:14.138  INFO 1 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka data center value eureka.datacenter is not set, defaulting to default
2019-07-03 12:04:14.139  INFO 1 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka environment value eureka.environment is not set, defaulting to test
2019-07-03 12:04:14.181  INFO 1 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : isAws returned false
2019-07-03 12:04:14.182  INFO 1 --- [      Thread-11] o.s.c.n.e.server.EurekaServerBootstrap   : Initialized server context
2019-07-03 12:04:14.182  INFO 1 --- [      Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl    : Got 1 instances from neighboring DS node
2019-07-03 12:04:14.182  INFO 1 --- [      Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl    : Renew threshold is: 1
2019-07-03 12:04:14.183  INFO 1 --- [      Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl    : Changing status to UP
2019-07-03 12:04:14.225  INFO 1 --- [      Thread-11] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2019-07-03 12:04:14.253  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8761 (http) with context path ''
2019-07-03 12:04:14.259  INFO 1 --- [           main] d.h.d.DiscoveryServiceApplication        : Started DiscoveryServiceApplication in 12.423 seconds (JVM running for 13.3)
2019-07-03 12:05:14.187  INFO 1 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms
2019-07-03 12:06:14.187  INFO 1 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms

容器信息

CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS                    PORTS                    NAMES
8994d80a4ee2        marcelv93/service-discovery:latest   "java -Djava.securit…"   6 minutes ago       Up 6 minutes              0.0.0.0:8761->8761/tcp   api

【问题讨论】:

    标签: spring azure docker spring-cloud


    【解决方案1】:

    对于您的问题,您无法访问该容器。据我所知,可能的原因如下:

    1. 容器运行不正常。
    2. 容器运行良好,但应用程序在容器内运行不佳。
    3. 容器和应用程序都运行良好,但您暴露了错误的端口。该端口不是应用程序在容器内侦听的端口。

    所以你需要检查上面的点。我发现默认端口是8761,你需要设置配置。看看Containerize-Spring-Cloud-Eureka-Server

    【讨论】:

    • 我编辑了我的问题:我认为容器运行良好。我还将端口更改为 8761。但​​是当我输入服务器 ip-adress:8761/eureka 时,我仍然无法访问 eureka 仪表板。所以什么都没有发生......
    • @softwareUser 你确定你用来运行图像的方式对吗?它需要像服务器 URL 这样的东西吗?你在哪里找到图像?
    猜你喜欢
    • 2022-12-01
    • 2020-08-19
    • 2022-12-13
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    • 2020-05-26
    • 2017-08-16
    • 1970-01-01
    相关资源
    最近更新 更多