How to Fix Docker Out of Memory (OOM) on Debian 11


For WebToolsWiz.com, let’s tackle the “Docker Out of Memory (OOM)” issue on Debian 11 directly.


Troubleshooting Guide: Fixing Docker Out of Memory (OOM) on Debian 11

1. The Root Cause

On Debian 11, Docker Out of Memory (OOM) events often occur when the combined memory consumption of running containers exceeds the system’s available physical memory and swap space, or when the Linux kernel’s aggressive vm.overcommit_memory policy prematurely invokes the OOM killer. This results in the kernel terminating Docker containers or even the Docker daemon to free up resources.

2. Quick Fix (CLI)

If you’re currently experiencing an OOM event, a quick restart of the Docker daemon can temporarily clear cached memory and alleviate immediate pressure, allowing you to regain control and implement a permanent fix.

sudo systemctl restart docker

3. Configuration Check

The most effective long-term solution involves adjusting the kernel’s memory overcommit policy to be more lenient, which prevents the OOM killer from being overly aggressive with Docker workloads.

Edit or create a new sysctl configuration file to persist this setting across reboots. We recommend creating a dedicated file for clarity:

sudo nano /etc/sysctl.d/99-docker-memory.conf

Add the following line to the file:

vm.overcommit_memory = 1

This setting instructs the kernel to always allow memory allocation, deferring the OOM decision until actual memory exhaustion occurs. Save the file and exit the editor.

Apply the new sysctl configuration immediately:

sudo sysctl -p /etc/sysctl.d/99-docker-memory.conf

4. Verification

To confirm that the vm.overcommit_memory setting has been successfully applied, execute the following command:

sysctl vm.overcommit_memory

The output should display vm.overcommit_memory = 1. Monitor your Docker container performance using docker stats and overall system memory with free -h to confirm improved stability.