Set Container Memory

The following sections describe how to set certain Docker and JVM options.

Set Docker Container Memory

During initial creation of the Docker container only, use -Xmx and -Xms in the JAVA_MEMORY_OPTS environment variable in docker-compose.yaml to adjust the memory available to the Docker container.

Example:
JAVA_MEMORY_OPTS: "-Xms6g -Xmx6g"
A sample docker-compose.yaml file can be found in the Github community-examples repository.

On Linux, Docker is constrained by the host machine’s memory. On Windows, using Docker Desktop with WSL, memory is constrained by the memory allocated for WSL in the %USERPROFILE%\.wslconfig file. For example, the following setting limits the machine to 6GB of memory, which cannot be exceeded by any Docker container:

Example:
[wsl2]
memory=6GB

To change the Docker container memory at a later time, stop the existing container and start a new container with the desired memory setting.

Add New JVM Options

During initial creation of the Docker container only, use the JAVA_TOOL_OPTIONS line in the docker-compose.yaml file to add new JVM options. You can add multiple options to the same line, separated with a space.

Example:
environment:
  JAVA_MEMORY_OPTS: "-Xms6g -Xmx6g"
  JAVA_TOOL_OPTIONS: "-Djava.io.tmpdir=/tmp/directory/ -XX:+PrintGCDetails"
A sample docker-compose.yaml file can be found in the Github community-examples repository.