Windows Docker - Keycloak memory limits

Hello,

I was checking the Server Info on my current dev Windows docker instance of Keycloak and I was wondering about the stated memory limits, currently it tells me I have a Total Memory of ‘512 MB’ but for the docker container on creation I set it up with 2GB:

kc-mem

If I check the docker container via PowerShell I can see it has a 2GB limit and 537.8MB in use:

How can I increase the Total memory for my Keycloak instance? The container itself will only run Keycloak and nothing else so makes sense for the limit to be increased.

Thanks for any help!

Steve

This one seems to be related to the JVM inside the container being set to take a maximum of 25% RAM (I think):

I’ve increased that via calls on a running container using -XX:MaxRAM and -XX:MaxRAMPercentage but it hasn’t changed the Total Memory output on Keycloak’s ‘Server Info’ page (I’m assuming the JVM needs to start afresh), I’m trying different ways to see if I can increase the RAM usage with those commands on the initial Docker run call but no joy so far.

Ok I’ve potentially had some success using the following as a test:

docker run --name keycloak --memory 3072m ... ...... -e JAVA_OPTS_APPEND="-server -Xms1024m -Xmx2048m"

Which sets an initial heap size (Xms) of 1gb and then a max heap size (Xmx) of 2gb on a container with 3gb and is also indicated on the ‘Server Info’ page:

kc-mem

The container is currently using 1gb according to the stats (shown below) and I’m assuming that will increase to 2gb if Keycloak needs it:

I don’t know the full implications of this yet because I haven’t tested load in a live environment but it’s encouraging at least. It would be good to have more info on ths type of thing on the Keycloak docker readme (https://github.com/keycloak/keycloak-containers/blob/12.0.4/server/README.md) but maybe it’s out of scope / risky to play around with? I tried to find info about whether it’s automcatically setup with UseContainerSupport and automatically expanding RAM but couldn’t find the details about this.

1 Like