首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Docker拒绝连接本地主机

问Docker拒绝连接本地主机
EN

Stack Overflow用户
提问于 2020-03-13 11:20:55
回答 2查看 3.9K关注 0票数 3

我有一个问题,我的篡改网络应用程序。本质上,我有一个坞-组成yaml文件,当文件运行时,一切似乎顺利启动。我可以看到容器正在使用docker运行。我可以看到它正在监听正确的端口,但是当我试图通过我的浏览器连接时,它拒绝连接。

我的yaml档案

代码语言:javascript
复制
version: '3'
services:
  product-search-service:
    build: ./product-search-app
    ports:
      - 8000:5000
  product-shipping-service:
    build: ./product-shipping-app
    ports:
      - 9000:5000
  website-app:
    build: ./web-app
    ports:
      - 127.0.0.1:8080:80
    volumes:
      - ./web-app/public-html:/usr/local/apache2/htdocs/ 

我通过网络浏览器连接到127.0.0.1:8080

控制台日志

代码语言:javascript
复制
Starting webstore-services_product-shipping-service_1 ... done                                                                                               Recreating webstore-services_website-app_1            ... done                                                                                               Starting webstore-services_product-search-service_1   ... done                                                                                               Attaching to webstore-services_product-shipping-service_1, webstore-services_product-search-service_1, webstore-services_website-app_1
website-app_1               | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message
website-app_1               | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message
website-app_1               | [Fri Mar 13 11:09:16.255235 2020] [mpm_event:notice] [pid 1:tid 140304540900680] AH00489: Apache/2.4.41 (Unix) configured -- resuming normal operations
product-search-service_1    |
product-search-service_1    |   .   ____          _            __ _ _
product-search-service_1    |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
product-search-service_1    | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
product-search-service_1    |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
product-search-service_1    |   '  |____| .__|_| |_|_| |_\__, | / / / /
product-search-service_1    |  =========|_|==============|___/=/_/_/_/
product-search-service_1    |  :: Spring Boot ::        (v2.0.5.RELEASE)
product-shipping-service_1  |
product-shipping-service_1  |   .   ____          _            __ _ _
product-shipping-service_1  |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
product-shipping-service_1  | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
product-shipping-service_1  |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
product-shipping-service_1  |   '  |____| .__|_| |_|_| |_\__, | / / / /
product-shipping-service_1  |  =========|_|==============|___/=/_/_/_/
product-shipping-service_1  |  :: Spring Boot ::        (v2.0.5.RELEASE)
product-search-service_1    |
product-search-service_1    | 2020-03-13 11:09:25.557  INFO 1 --- [           main] product.App                              : Starting App v0.1.0 on 82a04050f513 with PID 1 (/app/product-search-service-0.1.0.jar started by root in /app)
product-shipping-service_1  |
product-shipping-service_1  | 2020-03-13 11:09:25.743  INFO 1 --- [           main] shipping.App                             : Starting App v0.1.0 on 21735f5ffb12 with PID 1 (/app/product-shipping-service-0.1.0.jar started by root in /app)
product-search-service_1    | 2020-03-13 11:09:25.607  INFO 1 --- [           main] product.App                              : No active profile set, falling back to default profiles: default
product-shipping-service_1  | 2020-03-13 11:09:25.800  INFO 1 --- [           main] shipping.App                             : No active profile set, falling back to default profiles: default
product-search-service_1    | 2020-03-13 11:09:26.461  INFO 1 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3339ad8e: startup date [Fri Mar 13 11:09:26 GMT 2020]; root of context hierarchy
product-shipping-service_1  | 2020-03-13 11:09:26.606  INFO 1 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3c679bde: startup date [Fri Mar 13 11:09:26 GMT 2020]; root of context hierarchy
product-search-service_1    | 2020-03-13 11:09:41.208  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 5000 (http)
product-search-service_1    | 2020-03-13 11:09:41.583  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
product-search-service_1    | 2020-03-13 11:09:41.584  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.34
product-shipping-service_1  | 2020-03-13 11:09:41.540  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 5000 (http)
product-shipping-service_1  | 2020-03-13 11:09:41.914  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
product-shipping-service_1  | 2020-03-13 11:09:41.923  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.34
product-search-service_1    | 2020-03-13 11:09:41.708  INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
product-search-service_1    | 2020-03-13 11:09:42.613  INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
product-shipping-service_1  | 2020-03-13 11:09:42.043  INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
product-shipping-service_1  | 2020-03-13 11:09:42.873  INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
product-search-service_1    | 2020-03-13 11:09:42.615  INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 16228 ms
product-search-service_1    | 2020-03-13 11:09:43.319  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
product-search-service_1    | 2020-03-13 11:09:43.355  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
product-search-service_1    | 2020-03-13 11:09:43.364  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
product-search-service_1    | 2020-03-13 11:09:43.370  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
product-shipping-service_1  | 2020-03-13 11:09:42.874  INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 16315 ms
product-shipping-service_1  | 2020-03-13 11:09:43.471  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
product-shipping-service_1  | 2020-03-13 11:09:43.505  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
product-shipping-service_1  | 2020-03-13 11:09:43.508  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
product-shipping-service_1  | 2020-03-13 11:09:43.517  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
product-search-service_1    | 2020-03-13 11:09:43.371  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
product-shipping-service_1  | 2020-03-13 11:09:43.521  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
product-search-service_1    | 2020-03-13 11:09:44.733  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-shipping-service_1  | 2020-03-13 11:09:44.846  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-search-service_1    | 2020-03-13 11:09:46.595  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3339ad8e: startup date [Fri Mar 13 11:09:26 GMT 2020]; root of context hierarchy
product-shipping-service_1  | 2020-03-13 11:09:46.656  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3c679bde: startup date [Fri Mar 13 11:09:26 GMT 2020]; root of context hierarchy
product-search-service_1    | 2020-03-13 11:09:47.356  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product]}" onto public product.Product product.ProductController.product(java.lang.String)
product-search-service_1    | 2020-03-13 11:09:47.448  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
product-shipping-service_1  | 2020-03-13 11:09:47.426  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/shipping]}" onto public shipping.Shipping shipping.ShippingController.shipping(long)
product-shipping-service_1  | 2020-03-13 11:09:47.491  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
product-search-service_1    | 2020-03-13 11:09:47.451  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
product-search-service_1    | 2020-03-13 11:09:47.758  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-shipping-service_1  | 2020-03-13 11:09:47.495  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
product-shipping-service_1  | 2020-03-13 11:09:47.773  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-search-service_1    | 2020-03-13 11:09:47.763  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-shipping-service_1  | 2020-03-13 11:09:47.778  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
product-search-service_1    | 2020-03-13 11:09:49.191  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
product-shipping-service_1  | 2020-03-13 11:09:49.232  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
product-shipping-service_1  | 2020-03-13 11:09:49.633  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 5000 (http) with context path ''
product-search-service_1    | 2020-03-13 11:09:49.612  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 5000 (http) with context path ''

我还想指出,我一直在学习本教程,我可以确认以前的所有步骤都已正确完成,就像我已经多次这样做了一样。

https://cpit490.gitlab.io/labs/lab-8/

当我试图连接到127.0.0.1时,是否有任何日志功能可以让我更好地查看发生了什么?

编辑

附加错误的屏幕截图

​

​

编辑2

web应用程序的Dockerfile

代码语言:javascript
复制
FROM httpd:2-alpine
EXPOSE 80
EXPOSE 443

编辑3

我正在使用docker工具箱,以防这会造成任何不同。我没有win10 pro或企业,所以我不得不使用工具箱

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-03-13 14:23:27

所以我已经解决了这个问题。

因为我在Win10主页上运行Docker,所以我的码头从拥有自己IP地址的VirtualBox上运行。要连接到我的webapp,我需要使用VB的IP,而不是我的本地主机。Win10 home没有虚拟机管理程序,因此本地主机基本上被我拒之门外:

贷给Docker Toolbox - Localhost not working

票数 0
EN

Stack Overflow用户

发布于 2020-03-13 12:07:49

您似乎没有正确地将容器的端口映射到localhost。更新yaml文件如下:

代码语言:javascript
复制
version: '3'  
services:      
product-search-service:

          build: ./product-search-app
          ports:
            - 8000:80
            - 8001:443      
product-shipping-service:

          build: ./product-shipping-app
          ports:
            - 9000:80
            - 9001:443      
website-app:

          build: ./web-app
          ports:
            - 8080:80
            - 8081:443
          volumes:
            - ./web-app/public-html:/usr/local/apache2/htdocs/

现在您可以浏览localhost:8080或localhost:8081。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60669552

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档