I have a setup where I'm running two (and soon three) Docker containers for a Minecraft server, with a total of 32GB of RAM available on my system. The problem I'm facing is that if I allocate 24GB of RAM for each container, I'm concerned about running into memory issues and encountering OOM-kills. I'm hoping to find a way to set a combined memory limit of 24GB across all three containers and have them share the available resources based on their needs. While I've come across the idea of using memory reservations, it seems more about priority than a strict limit. Am I overlooking something obvious, or are there clever workarounds to achieve this? I also just learned about cgroups, which seems promising, but I'm open to any additional advice!
4 Answers
If you really want to limit your memory usage across those containers without Kubernetes, consider creating a virtual machine and capping its RAM. You could use a lightweight VM like Docker Moby for this.
If those three containers are your entire workload, you can actually set a memory limit for Docker itself, which will control how much memory the containers can use in total.
Why not try using Podman instead? It has pod functionality that might help you manage multiple containers more effectively.
You can't set a strict limit like that with just Docker. It seems like Kubernetes could handle it, but that's kind of complex for your situation. You can set soft and hard limits for each container, and this might help a little. Monitoring how much memory each container actually needs is key. They probably won’t all need 20GB at once. Using swap space could be a good buffer to prevent crashes if memory demands spike!

Related Questions
Ray Trace Simulator – Interactive Optical Ray Tracing Tool
Wordsearch Generator
Random Maze Generator and Solver
Interactive Wheel Spinner Tool – Add Choices and Randomly Pick a Winner
Raffle Ticket Generator
Instant Online Dice Roller