Problem: I have Dockerized a Spring Boot application, but when I run the container, it doesn’t respond to any HTTP requests. The non-Dockerized version works fine. How should this issue be handled?
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9c29bd8e24d6 rezos/tourmappers-rezg-thirdparty-activity-service:2.1.2 "java -jar rezg-thir…" 7 minutes ago Up 7 minutes 0.0.0.0:8380->8080/tcp, [::]:8380->8080/tcp tourmappers-rezg-thirdparty-activity-service
I did check the container Logs, but nothing was print there related to the request made.So I assume It was not reaching the application.
Logs only indicate the standard message printed when starting that application
$ docker logs 9c29bd8e24d6
. __ _ __ _ _
/\\ / _'_ _ _ _()_ _ _ _ \ \ \ \
( ( )\_ | '_ | '| | ' \/ _` | \ \ \ \
\\/ _)| |)| | | | | || (| | ) ) ) )
' |_| .|| ||| |\_, | / / / /
=========||==============|_/=////
:: Spring Boot :: (v2.7.4)
09:42:48.853 [main] INFO r.t.a.s.RezgThirdpartyActivityServiceApplication - Starting RezgThirdpartyActivityServiceApplication using Java 11.0.8 on 9c29bd8e24d6 with PID 1 (/rezg-thirdparty-activity-service.jar started by root in /)
09:42:48.858 [main] INFO r.t.a.s.RezgThirdpartyActivityServiceApplication - No active profile set, falling back to 1 default profile: "default"
09:42:50.554 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8080 (http)
09:42:50.574 [main] INFO o.a.catalina.core.StandardService - Starting service [Tomcat]
09:42:50.574 [main] INFO o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.65]
09:42:50.688 [main] INFO o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
09:42:50.688 [main] INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 1721 ms
09:42:51.808 [main] INFO o.s.b.a.e.web.EndpointLinksResolver - Exposing 3 endpoint(s) beneath base path '/actuator'
09:42:51.862 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path ''
09:42:51.885 [main] INFO r.t.a.s.RezgThirdpartyActivityServiceApplication - Started RezgThirdpartyActivityServiceApplication in 3.841 seconds (JVM running for 4.417)
gehan@gehan-Inspiron-3580:~$
Another point is that the same application is deployed on the Staging server and the Production server. But it functions fine on these servers. I am trying to verify a bug on the Developer environment. Could it be some configurations are off in developer environment? Anything specific areas to compare in these environments that may help identify the issue?
The embedded tomcat starts, listens on port 8080 and marks the application as started, so things should be fine.
I am only uncertain about this:
Shouldn’t the default behavior of the embedded tomcat be to bind 0.0.0.0. This is needed, as the host’s localhost and the container’s localhost or not the same. The process inside the container must bind the port to 0.0.0.0, in order for published host ports to reach the container port.
Did you configure server.address=localhost in the application.properties? Either remove the line completely or set 0.0.0.0 and re-create the image.
But this too did not give the desired results. I have added how the same application is deployed in staging and production using very similar commands as used in the developer environment, but it works fine in these live environments
The commands used to deploy to the production and staging servers are similar to the steps followed in the development environment.
It should work like this. No idea why it’s not working for you.
Btw. the container arguments (the one right to the image) mean nothing without knowing your entry point script. Furthermore, the tail -f /dev/null looks somewhat odd, if the entrypoint is done correct, a Spring Boot app should not need it, as it’s a foreground process.