1. Current Location: Home >  NAS >  NAS runs nine Docker containers, but what crushes 8G is peak, not quantity

NAS runs nine Docker containers, but what crushes 8G is peak, not quantity

How many Docker containers can a NAS run? Comparing steady-state and peak ledgers

Installing containers is just like installing mobile apps back in the day. I installed a Docker container on Feiniu, starting from the earliest qBittorrent downloader to now nine: downloading, watching movies, listening to music, reading e-books, reading comics, managing whole-house smart devices, removing ads, managing photos, and managing passwords. Every time I installed something, I thought, "Just a little bit more," until one morning last month, when the AdGuard backend made me log in again—the running time was only six hours, and the container had been tampered with in the middle of the night.

To clarify: containers don't consume a single memory portion, but two ledgers of "steady-state + peak."

Many people calculate container accounts by multiplying the number of containers by the average, for example, "One container consumes 300 trillion, 8GB can run twenty." This algorithm barely works for honest containers like downloaders and ad removal, but real big players on NAS don't follow this rule.

My Home Assistant is steady-state at 430MB, unbeatable; Jellyfin usually has 310 megabytes, but it jumps up once transcoding; The most impressive is Immich. Normally, it runs over 600MB, which is quite mild, but once facial recognition is used, the memory goes up to over 3GB. If you only look at "normal," you'll think 8GB of RAM is generous enough to install ten more units; If you only watch "those two days of running recognition," you might think this machine is about to explode. Only by keeping separate accounts does you know how much balance your NAS actually has left.

The order for the ledger was just one line:

docker stats --no-stream

Without --no-stream, it will keep flashing, and with this parameter, it just gets a snapshot and leaves. The MEM USAGE column shows actual memory; if the MEM USAGE / LIMIT column is a percentage, it means you set a limit for the container. If not, it shows container occupied memory divided by total host memory. Feiniu types this command in SSH or on the container detail page; the number is a source.

The storage ledger for nine containers in my home looks like this

I chose a Sunday afternoon when all the family devices were online and no recognition tasks were running, so I copied the snapshot

: , ; up/down codes. Gradually ; and above ; stable , removed , The
What is the container for? Use steady-state memory, peak temper
Immich set photo library, 620MB and above, face recognition, and Home up to 3G
Assistant whole-house smart hub is stable at 430M, basically no spike
Jellyfin Movie Library at 310M boosts when converting
qBittorrent download is protected increasing the number of seeds around 180M
Komga comic library at 260M7000MB; full library scanning at 700-800MB
calibre-web e-booksat 120M
Navidrome music library is stable around 90M
AdGuard Home FamilyMart ads areabove and below, 60M is as steady as a brick
Vaultwarden password database is written in Rust for about 30MB, with almost no changes

Nine combined are around 2.1GB, plus the Feiniu system itself and various caches, free-to-H uses up just over 3GB, with more than half of the 8GB machines left. Just looking at this chart, you'll conclude that 'five more is fine.' That's exactly what I thought at the beginning.

The time I stumbled: two peaks collided together

The night the incident happened, I did something: I replaced the Chinese search model for Immich. The database of over 40,000 photos had to be re-encoded and face-sized, so I spent half the night letting it run on its own. As a result, Komga's regular full-library scans happened to be scheduled for that night, so the two jobs overlapped.

Immich's machine learning container is fully loaded with 3GB, Komga scans climb to over 700MB, plus seven other steady-state modules, so the container is aiming for 5GB. The system subtracts one more, and the next morning I checked the free -h column, and the available column was only about 400MB. Don't look at the 'free' column when looking at 'available'—'free' counts file cache as 'used'; 'available' is the money the system can actually pay.

Then it was AdGuard's turn to be unlucky. A little after 2 a.m., it was killed by the core with a single slash. The next morning, when I logging into the AdGuard backend and logging in again, the runtime reset to zero, my first reaction was to think Feiniu had updated something. Only after checking SSH did I understand:

In docker ps -a, the bar shows Exited (137). This 137 isn't a random number; 128 plus 9, 9 is SIGKILL, the kernel's doing. One more quick confirmation:

docker inspect container name --format '{{. State.OOMKilled}} {{. State.ExitCode}}'

Returned to true 137, confirming insufficient memory and killing. AdGuard usually only has 60 megabytes—who else would it be better to kill? Because the kernel picks the unlucky ones not by size; whoever happens to request memory at the most tight moment gets stabbed. It handles the family's DNS and queries every second in the middle of the night, making it easy to get into trouble.

Containers disappearing in the middle of the night? First, let's see if it was killed by 137

After this incident, I summarized the inspection order: someone at home had a container that mysteriously restarted, so I followed it

Step one: Docker ps -a to check the status. Note down the numbers in parentheses after Exited: 137 means memory was killed, 1 means the program itself reported an error, 143 means a normal stop signal was received (either a restart policy or a manual stop), 139 is an error, which is the program's own fault.

Step two: 137 checks the internal storage account. Save a snapshot of Docker stats --no-stream and compare it with the time of the incident—is it a peak container doing heavy work, or have you recently installed something new?

Step three: If not 137, check the log. docker logs --tail 100 Container names are about a hundred lines in the last hundred, and most program errors are inside. I used to always get the order backwards: as soon as the container rebooted, I would check the log first, and after a long time, nothing would be found—the process killed by the kernel never leaves a message in the log.

Three Ways to Reduce Load: Cut, Limit, Swap

After settling the accounts, I did three things, sorting from severity to severity:

The first step is chopping. Merging overlapping containers: Movie poster wall Feiniu's built-in video app can also work, but I cut a backup library from Jellyfin; Previously, I used to install a container specifically for lyrics, and Navidrome could scratch the cover itself and cut it off. This step is not painful; after cutting steady state, you save nearly 500 trillion.

The second is the 'Limit Axe.' Put a cage on a peak-type container, and add a parameter when creating a new container:

docker run -m 512m --memory-swap 512m ...

-m is the maximum memory limit. I set a limit of 768MB on Komga—scan slower as well, but scanning is never rushed, no need to drag the whole machine down. Note: Don't limit Immich, which really does heavy work. If you limit it to 1G for 3G recognition, it won't be 'persuaded' to use it less, but will just be repeatedly killed, and the recognition tasks will never be completed. Restrictions are for containers where 'peaks are meaningless,' not for containers where 'peaks are business.'

The third method is to change. AdGuard Home can't be changed, but it's already the most economical in its class; But I set my restart strategy to always confirm it, got up after being killed, and if DNS was disconnected for a few seconds, my family wouldn't feel anything. Staggered reactivity: I switched Immich's recognition to manual triggering, running it when no one was home during the day, and changed Komga's scanning interval from daily to weekly. Also, change the Watchtower automatic container upgrade system to just focus on one or two unconditioned ones. Other manual upgrades—update storms, when a dozen containers are refreshed and reboot at the same time, it's a small peak. Peaks aren't scary; stacking two peaks together is scarier. If you stagger them, you'll each go their own way.

When will it be time to add memory

?

After all three strategies, my home currently has steady-state 3G, peak support around 5G, and still 8G to spare. I'll keep using this N100. When it reaches the point where you can't cut or limit it, and the peak is always at full limits, then it's time to spend money.

Before paying, check the device: some NAS memory is soldered onboard, so there's no way to add it, so either change the device or resign yourself to running less; For those with empty slots, whether upgrading from 4G to 8G or 8G to 16G, I wrote a separate article before. All three tiers are listed for real-world tests, and the links are here. There's one more detour: don't count on swaps to save you. Insufficient memory causes the system to crash onto the drive; mechanical drives are struggling to swap the whole machine down to the mouse. This isn't just reducing burden, it's diluting pain.

Finally, here's a checkmark

: What should you ? . . the
do first for your situation
You haven't installed containers yet, but the plan is to allocate two ledgers based on steady-state + peak values, with peak type staggered operation
Installed five or six units, and nothing has ever happenedDocker Stats copies a base ledger and stores it. If something happens, it's correct
The container mysteriously restarts at midnight, first checks 137, then checks the memory ledger, and finally checks the logs.
After the cut, after the limit, checkmemory slots—
add and replace as needed

The number of containers has never been the answer; peak management is. My family's nine are running happily, while others' five are crashing every day. The problem isn't the memory stick, but whether those two ledgers are recorded separately.

The three terms Docker are still confusing, so let's first catch up on the lesson on mirroring, port mapping, and directory mounting; Immich installation and Chinese search model, How much memory does Home Assistant consume, Komga and calibre-web comic libraries, Jellyfin and Feiniu Films, AdGuard Home full house ad removal, Vaultwarden Password Database, qBittorrent Downloader—each article provides detailed accounts. the bridge and host network modes of containers, how to upgrade containers without losing data—this article makes a perfect combination. three-level hands-on test of memory upgrade or not, left to that article to wrap up.

Read More


Copyright Notice Scan to read on mobile
All Rights Reserved: 《SHUNOT》 => 《NAS runs nine Docker containers, but what crushes 8G is peak, not quantity》
Article URL: https://www.shunot.com/en/nas/1331.html
Unless otherwise stated, all articles are original by 《SHUNOT》. Reposting is welcome! Please indicate the original URL when reposting, thank you.

Contact Us

Online Consultation: Click here to send me a message

WeChat ID: master_135

Scan to follow