brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: add --memory=2g to a container's Extra Parameters to cap its RAM

Docker
~/tips/tip-unraid-container-memory-limit

--memory=2g --memory-swap=2g

Caps how much memory one Docker container may use, so it cannot starve the rest of the server.

One container with a memory leak can take the whole server down with it. Docker has a flag to put a ceiling on it.

In the Docker tab, switch to Advanced View (top right), edit the container and fill the Extra Parameters field:

--memory=2g --memory-swap=2g

The Docker docs say --memory is the maximum amount of memory the container can use, with a minimum of 6m. --memory-swap only works together with --memory. It is the total of RAM and swap, so a value equal to --memory means no swap.

The caveat is what happens at the limit: by default the kernel kills processes inside the container when it runs out of memory, so a limit that is too tight looks like random crashes. The Docker docs warn against --oom-kill-disable. The Unraid docs only mention Advanced View and do not describe these flags, so this comes from the Docker documentation. I would start generous and look at how much the container actually uses.

Further reading: Docker docs: Resource constraints, Unraid docs: Managing and customizing containers, On this site: use Previous Apps to bring back every container after deleting docker.img, On this site: give Docker containers a wait time in the Unraid autostart column

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link