Spring boot connection reset after a few minutes in docker container Spring boot connection reset after a few minutes in docker container docker docker

Spring boot connection reset after a few minutes in docker container


I had the same problem months ago!This happens because the jvm doesn’t have memory enough to accept this request!

This error is intermittent and is very difficult to find your root cause!

Try this:Put in your Dockerfile some flags to solve it

ENTRYPOINT ["java","-XX:+TieredCompilation","-XX:TieredStopAtLevel=1", "-jar","yourJar.jar"]

More details here: https://jpbempel.github.io/2020/05/22/startup-containers-tieredcompilation.html

Sometimes the problem can be memory. When you start your container with java, the jvm default heap memory is 1/4 of total memory of container.Then you can use the flag -XX:MaxRAMFraction where your value has a range 1 to 4.

More details here: https://merikan.com/2019/04/jvm-in-a-container/#java-8u131-and-java-9

Good luck!