'm trying to setup a self-hosted OpenRouteService instance with Docker to perform some operations I need for a QGIS analysis. Following the instructions from the official documentation and from this video I managed to have some of the services I need, but to go on I need to download new stuff to add on my Docker.
However, when I run Docker compose up I get an error. With the help of other people from the OpenRouteService forum we found out the problem was due to allocate more RAM to the Docker instance or more RAM to the java runtime in the docker.
This is a sample from the error log:
Caused by: java.lang.OutOfMemoryError: Java heap space
I already changed settings in OpenRouteService to allocate more resources, but I have no idea of how to allocate more RAM to the Docker instance.
From Docker Desktop > Settings > Resources I found out that I’m using a WSL2 backend, and so I have to use a wslconfig file.
I’m stucked here in this phase.
You can find more information here
It links the Microsoft documentation:
which I think contains everything you need to know about .wslconfig any memory settings.
There are multiple factors that can lead to an OOM error with Java applications.
If a java application is run on a host, it will use 1/4th of the host memory for heap. In the early days of Docker the Java versions weren’t CGROUP aware and continued that habit. With Java >=11 CGROUP awareness should be default, which allows to controll the memory using with container resource constraints. With Java 8 it depends on the exact version whether CGROUP awareness is available or not.
If no resource constraints are set for a container, it will use whatever resources are available, which in your case is whatever the WSL2 distro provides.
Additionally, it might be that the maximum heap size (
-Xmx) was declared as argument for the java application, which might be set higher, than the available memory. I kind of remember that setting the maximum heap size with
-Xmx interferes with the CGROUP aware settings.
Without knowing your image, more specifically it’s Dockerfile and entrypoint script, the best thing we can do is to make educated guesses.
Hi and thanks for your kind reply.
I managed to solve the problem. As written before, I was trying to run openrouteservice in Docker with Windows but did not manage to configure correctly my
.wslconfig. I found this post with an example of configuration, and managed to add more RAM making all working right.
This was absolutely my first experience with Docker, so I got a little confused. Thanks again.