How to fix Minimum memory limit allowed is 6MB in Docker

DockerBEGINNERLOWUpdated Dec 6, 2025ยท 163 views

This error occurs when you try to set a container memory limit below Docker's minimum threshold of 6MB. The fix is straightforward: increase the memory limit to at least 6MB or remove the constraint entirely if no limit is needed.

Quick fix

Fixes Minimum memory limit allowed is 6MB

# If using docker run directly, check your command for -m or --memory flags
docker run --memory=4m myimage  # This will fail

# Check Docker Compose files for memory settings
grep -r "memory:" docker-compose*.yml
  1. Identify the problematic memory limit
  2. Increase the memory limit to at least 6MB
  3. Remove the memory limit if not needed
  4. Fix programmatic Docker API calls
docker โ€” error
# If using docker run directly, check your command for -m or --memory flags
docker run --memory=4m myimage # This will fail
# Check Docker Compose files for memory settings
grep -r "memory:" docker-compose*.yml
Minimum memory limit allowed is 6MB

What this error means

The "Minimum memory limit allowed is 6MB" error occurs when you attempt to create or run a Docker container with a memory limit (`--memory` or `-m` flag) set below 6 megabytes. Docker enforces this minimum because container runtimes like runc require a baseline amount of memory just to start a container, before any application code even runs. This minimum was raised from 4MB to 6MB in Docker Engine 20.10 (tracked in moby/moby#41168) to account for higher memory usage by modern container runtimes during startup. The limit applies to any memory constraint you set, whether via the Docker CLI, Docker Compose, or container orchestration tools. If you don't specify a memory limit, containers have no restriction and can use as much memory as the host kernel allows. The error only appears when you explicitly set a limit below the threshold.

Typical symptoms

  • docker run command fails with 'Minimum memory limit allowed is 6MB' error
  • docker-compose up fails when services have memory limits below 6MB
  • Container creation fails in orchestration tools (Kubernetes, Docker Swarm) with memory constraint errors
  • CI/CD pipelines fail at container start step with memory limit errors
  • Programmatic container creation via Docker API returns minimum memory error

Common causes

  1. Memory limit explicitly set below 6MB (e.g., --memory=4m or --memory=5m)
  2. Docker Compose file specifies memory limit under 6MB in deploy.resources.limits.memory
  3. Kubernetes pod spec has memory limits below 6MB
  4. Legacy configuration from older Docker versions that allowed 4MB minimum
  5. Attempting to run extremely lightweight containers with artificially low limits
  6. Memory limit passed in bytes rather than using proper unit suffixes (e.g., 5000000 instead of 6m)

How to fix "Minimum memory limit allowed is 6MB"

1Identify the problematic memory limit

First, find where the low memory limit is being set. Check your Docker command or configuration:

bash
# If using docker run directly, check your command for -m or --memory flags
docker run --memory=4m myimage  # This will fail

# Check Docker Compose files for memory settings
grep -r "memory:" docker-compose*.yml

Look for any memory values below 6MB (6m, 6000000 bytes, or 0.006g).

2Increase the memory limit to at least 6MB

Update your memory limit to 6MB or higher:

Docker CLI:

bash
# Minimum valid memory limit
docker run --memory=6m myimage

# A more practical limit for most applications
docker run --memory=64m myimage

Docker Compose (v3 with deploy):

yaml
services:
  myapp:
    image: myimage
    deploy:
      resources:
        limits:
          memory: 64M
        reservations:
          memory: 32M

Docker Compose (v2 syntax):

yaml
services:
  myapp:
    image: myimage
    mem_limit: 64m
    mem_reservation: 32m

Memory unit suffixes: b (bytes), k (kilobytes), m (megabytes), g (gigabytes).

3Remove the memory limit if not needed

If you don't actually need to constrain memory, simply remove the limit:

Docker CLI:

bash
# No memory limit - container uses available host memory
docker run myimage

Docker Compose:

yaml
services:
  myapp:
    image: myimage
    # Remove any memory-related fields:
    # - mem_limit
    # - memory
    # - deploy.resources.limits.memory

By default, containers have no memory constraints and can use as much memory as the host allows.

4Fix programmatic Docker API calls

If you're creating containers programmatically, ensure memory is specified correctly:

Docker SDK for Python:

python
import docker
client = docker.from_env()

# Memory in bytes - must be at least 6MB (6291456 bytes)
container = client.containers.run(
    "myimage",
    mem_limit="64m"  # Use string with unit suffix
)

Docker API (direct HTTP):

bash
curl -X POST "http://localhost:2375/containers/create" \
  -H "Content-Type: application/json" \
  -d '{"Image": "myimage", "HostConfig": {"Memory": 67108864}}'

The Memory value is in bytes. 6291456 bytes = 6MB minimum.

spotify/docker-client (Java):

java
// Memory in bytes
HostConfig hostConfig = HostConfig.builder()
    .memory(67108864L)  // 64MB in bytes
    .build();
5Update Kubernetes resource limits

For Kubernetes deployments, ensure pod memory limits are at least 6Mi:

yaml
apiVersion: v1
kind: Pod
metadata:
  name: myapp
spec:
  containers:
  - name: myapp
    image: myimage
    resources:
      limits:
        memory: "64Mi"  # Must be >= 6Mi
      requests:
        memory: "32Mi"

Note: Kubernetes uses binary units (Mi = mebibytes), while Docker uses decimal (m = megabytes). 6Mi is slightly more than 6m.

For very small containers, consider if you really need such tight limits. Most applications need significantly more than 6MB to run effectively.

Advanced notes

Why 6MB minimum? Docker raised the minimum memory limit from 4MB to 6MB in Docker Engine 20.10 to account for increased memory usage by container runtimes (runc, containerd) during container startup. Even before your application code runs, the runtime needs memory for process initialization, namespace setup, and cgroup configuration.

Historical context: If you have older Docker configurations or scripts that used 4MB limits, they will break when upgrading to Docker 20.10+. Update these to at least 6MB.

Memory limit vs. memory reservation:
- --memory / mem_limit: Hard limit - container cannot exceed this
- --memory-reservation / mem_reservation: Soft limit - Docker tries to maintain but can exceed under memory pressure

Practical minimums by application type:
- Static file server (nginx): 32-64MB
- Node.js application: 128-256MB
- Java application: 256MB-1GB (JVM overhead)
- Python/Ruby application: 64-256MB

Testing with minimal containers: If you're experimenting with minimal memory limits for testing purposes, consider using the --memory-swap flag to allow some flexibility:

bash
docker run --memory=6m --memory-swap=12m myimage

This allows 6MB RAM + 6MB swap for a total of 12MB.

Frequently asked questions

What does "Minimum memory limit allowed is 6MB" mean?
The "Minimum memory limit allowed is 6MB" error occurs when you attempt to create or run a Docker container with a memory limit (--memory or -m flag) set below 6 megabytes. Docker enforces this minimum because container runtimes like runc require a baseline amount of memory just to start a container, before any application code even runs. 10 (tracked in moby/moby#41168) to account for higher memory usage by modern container runtimes during startup.
How do I fix "Minimum memory limit allowed is 6MB"?
This error occurs when you try to set a container memory limit below Docker's minimum threshold of 6MB. The fix is straightforward: increase the memory limit to at least 6MB or remove the constraint entirely if no limit is needed.
What causes "Minimum memory limit allowed is 6MB"?
Memory limit explicitly set below 6MB (e.g., --memory=4m or --memory=5m) Docker Compose file specifies memory limit under 6MB in deploy.resources.limits.memory Kubernetes pod spec has memory limits below 6MB
Is the "Minimum memory limit allowed is 6MB" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading