How to fix Minimum memory limit allowed is 6MB in Docker
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- Identify the problematic memory limit
- Increase the memory limit to at least 6MB
- Remove the memory limit if not needed
- Fix programmatic Docker API calls
# If using docker run directly, check your command for -m or --memory flagsdocker run --memory=4m myimage # This will fail# Check Docker Compose files for memory settingsgrep -r "memory:" docker-compose*.ymlMinimum 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
- 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
- Legacy configuration from older Docker versions that allowed 4MB minimum
- Attempting to run extremely lightweight containers with artificially low limits
- 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"
First, find where the low memory limit is being set. Check your Docker command or configuration:
# 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*.ymlLook for any memory values below 6MB (6m, 6000000 bytes, or 0.006g).
Update your memory limit to 6MB or higher:
Docker CLI:
# Minimum valid memory limit
docker run --memory=6m myimage
# A more practical limit for most applications
docker run --memory=64m myimageDocker Compose (v3 with deploy):
services:
myapp:
image: myimage
deploy:
resources:
limits:
memory: 64M
reservations:
memory: 32MDocker Compose (v2 syntax):
services:
myapp:
image: myimage
mem_limit: 64m
mem_reservation: 32mMemory unit suffixes: b (bytes), k (kilobytes), m (megabytes), g (gigabytes).
If you don't actually need to constrain memory, simply remove the limit:
Docker CLI:
# No memory limit - container uses available host memory
docker run myimageDocker Compose:
services:
myapp:
image: myimage
# Remove any memory-related fields:
# - mem_limit
# - memory
# - deploy.resources.limits.memoryBy default, containers have no memory constraints and can use as much memory as the host allows.
If you're creating containers programmatically, ensure memory is specified correctly:
Docker SDK for 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):
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):
// Memory in bytes
HostConfig hostConfig = HostConfig.builder()
.memory(67108864L) // 64MB in bytes
.build();For Kubernetes deployments, ensure pod memory limits are at least 6Mi:
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:
docker run --memory=6m --memory-swap=12m myimageThis 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
- ๐Docker Official Documentation
- ๐Docker Docs: Resource constraints(Official Docs)
- ๐Docker Engine v20.10 Release Notes(Official Docs)
- ๐ฌStack Overflow: Minimum memory limit allowed is 4MB failure(Stack Overflow)
- ๐
- ๐Docker Docs: docker container run(Official Docs)