使用docker镜像在Azure上部署Spring Eureka Service Registry

时间:2019-07-02 19:47:17

标签: spring azure docker spring-cloud

我创建了一个Docker Image并通过Docker Hub加载了它。然后尝试将其作为docker容器运行并暴露端口8080。该容器已列出,并且port列显示以下内容: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

1 个答案:

答案 0 :(得分:1)

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

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

因此,您需要检查以上几点。而且我发现默认端口为8761,您需要设置配置。看看Containerize-Spring-Cloud-Eureka-Server