Docker desktop eats memory despite limit

I’ve been trying to get Immich running using docker desktop. Sometimes all 8gb of ram are consumed and the system becomes unresponsive and sometimes docker desktop crashes at which point the memory usage drops to almost nothing. Why is the built in docker desktop resource limit feature for memory not keeping the memory usage below the setpoint? Is that not what it is for?

Immich involves 5 containers that run simultaneously. Are the docker desktop resource limiting applied to docker overall or to each container individually? In other words if I set the limit to 1gb of memory will each container get that for a total of 5gb or will 1gb be the total available for all 5 containers?

By default docker desktop was set to 3.3gb on my setup. I’ve tried changing it but it doesn’t seem to have an effect.

I should add that I have seem the same behavior when I limit the CPUs. All 4 CPUs still get pegged.

I launch my containers with docker compose from the command line. Do the limits in docker desktop not limit resources to containers running in docker compose?

Ok, I just discovered docker stats and I can see now that my 5 containers are all receiving whatever limit I set in docker desktop. So if I set docker desktop to 1gb of memory each container gets 1gb for a total of 5gb. That explains why my containers were still able to eat up all the ram and crash docker. What I really need is a global limit for all 5 containers and then just let them fight for what is available. I have no control over which of the 5 containers could be working harder than the others so I don’t want to limit them individually. Is it possible to limit all containers globally or reserve some amount to keep the host alive and available for other small task? If not through docker can this be done on the ubuntu side?