How Can I Set a Combined Memory Limit for Multiple Docker Containers?

0
10
Asked By TechyExplorer2023 On

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

Answered By VMMaster12 On

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.

Answered By Dockersmith On

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.

Answered By ContainerWizard99 On

Why not try using Podman instead? It has pod functionality that might help you manage multiple containers more effectively.

Answered By MemoryGuru92 On

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.