3

I am having an issue with my dockerized webapp. Essentially I have a docker-compose yaml file and when the file is ran, everything seems to boot up smoothly. I can see that the container is running using docker ps. I can see that it is listening to the correct ports, however when I try to connect via my browser, it refuses to connect.

My yaml file

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/ 

I am connecting via the web browser to 127.0.0.1:8080

The console logs

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 ''

I would also like to note that I have been following this tutorial and I can confirm that all prior steps were completed correctly as I have done this multiple times now

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

Are there any logging features I can enable to get a better look at whats happening when I try to connect to 127.0.0.1 ?

EDIT

Attaching screenshot of the error

enter image description here

EDIT 2

Dockerfile for the web-app

FROM httpd:2-alpine
EXPOSE 80
EXPOSE 443

Edit 3

I am using docker toolbox in case this makes any difference. I don't have win10 pro or enterprise so I had to use toolbox

LukeR97
  • 109
  • 2
  • 9
  • Please include the output of `docker run --rm --net container:${cid} nicolaka/netshoot ss -lnt` where `${cid}` is the container id for the website-app container. – BMitch Mar 13 '20 at 12:30
  • Hi @BMitch I am not sure if I have ran this correctly, but here is the command ran and the output I received $ docker run --rm --net container:b605c0901b9f nicolaka/netshoot ss -lnt Unable to find image 'nicolaka/netshoot:latest' locally C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 10.0.2.3:53: read udp 10.0.2.15:34228->10.0.2.3:53: i/o timeout. See 'C:\Program Files\Docker Toolbox\docker.exe run --help – LukeR97 Mar 13 '20 at 12:43
  • Do you have internet connectivity? Indicates that your DNS server could not find docker hub. If you're in a disconnected environment, you'll need to pull that image through other means first. – BMitch Mar 13 '20 at 12:49
  • The screenshot shows an attempt to connect to port 8081, not 8080 though... – Gimby Mar 13 '20 at 12:51
  • Yep have internet connectivity. I have some other docker projects which I've ran and they connect just fine. In regards to the port. I have tried 8080, 8081, 443, 80, etc. – LukeR97 Mar 13 '20 at 12:59
  • Try to pull the image, or run other commands that would cause the docker engine to use DNS. E.g. since you're on docker machine, the engine is in a VM, so `--net host` is the VM: `docker run --net host busybox ping google.com` – BMitch Mar 13 '20 at 13:34
  • My problem was that after I edited the `docker-compose.yml` (added port mapping) i only called `docker-compose restart` that did not recreate containers with ports mapped. – Najiva Sep 14 '22 at 10:48

2 Answers2

0

So I have figured out the issue.

Because I am running Docker Toolbox on Win10 home, my docker is running from VirtualBox which has its own IP address. To connect to my webapp, I need to use VB's IP instead of my local host. Win10 home doesn't have a hypervisor so localhost is essentially locked out from me :(

Credit goes to Docker Toolbox - Localhost not working

LukeR97
  • 109
  • 2
  • 9
-1

It seems that you didn't map correctly container's ports with localhost. Update your yaml file like below:

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/

Now you can browse to localhost:8080 or localhost:8081

Muneer Nasir
  • 83
  • 1
  • 9
  • Hey thank you for the answer. Unfortunately it didn't seem to work. I tried sending a curl request from command prompt, but even that refuses to connect. – LukeR97 Mar 13 '20 at 12:15
  • attached now. Network tab doesn't show any info just the document request – LukeR97 Mar 13 '20 at 12:23
  • now also EXPOSE ports of website-app (in dockerfile) like EXPOSE 80 EXPOSE 443 – Muneer Nasir Mar 13 '20 at 12:30
  • Tried this just now. Same result. I have included the full dockerfile for the web-app in the new edit. The dockerfile was provided by the tutorial I linked in my post, so I have just added the Exposes like you have asked – LukeR97 Mar 13 '20 at 12:46