How to fix runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: fork/exec: cannot allocate memory in Docker

DockerINTERMEDIATEHIGHUpdated Dec 6, 2025ยท 166 views

The system does not have enough memory to start the container. Free up memory by stopping unused containers, increasing system RAM, or adjusting container memory limits.

Quick fix

Fixes ENOMEM

# Overall memory
free -h

# Detailed memory info
cat /proc/meminfo | head -10

# Per-process memory usage
ps aux --sort=-%mem | head -10
  1. Check system memory usage
  2. Check Docker memory usage
  3. Stop unused containers
  4. Set container memory limits
docker โ€” error
# Overall memory
free -h
# Detailed memory info
cat /proc/meminfo | head -10
# Per-process memory usage
ps aux --sort=-%mem | head -10
runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: fork/exec: cannot allocate memory

What this error means

This error occurs when the Linux kernel cannot allocate memory for a new container process. The system may be out of physical RAM, swap space, or hitting cgroup memory limits. Docker containers share the host kernel and memory, so host memory pressure directly affects container creation. The error happens at the fork/exec stage when Docker tries to create the initial container process before the application even starts.

Typical symptoms

  • Container fails to start with memory allocation error
  • Error occurs immediately on docker run or docker-compose up
  • System is slow or unresponsive
  • Other containers may be OOM-killed at the same time
  • dmesg shows OOM (Out of Memory) killer messages

Common causes

  1. Host system is out of available memory
  2. Too many containers running simultaneously
  3. Existing containers consuming excessive memory
  4. Memory leak in running containers
  5. Insufficient swap space configured
  6. Container memory limit set too low
  7. Docker Desktop memory allocation is too small

How to fix "runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: fork/exec: cannot allocate memory"

1Check system memory usage

See current memory status:

bash
# Overall memory
free -h

# Detailed memory info
cat /proc/meminfo | head -10

# Per-process memory usage
ps aux --sort=-%mem | head -10

If available memory is very low, you need to free some up.

2Check Docker memory usage

See which containers are using memory:

bash
# Memory usage per container
docker stats --no-stream

# Detailed container resource usage
docker stats --format "table {{.Name}}	{{.MemUsage}}	{{.MemPerc}}"

Identify containers using excessive memory.

3Stop unused containers

Free memory by stopping unnecessary containers:

bash
# List all containers
docker ps -a

# Stop specific containers
docker stop <container_name>

# Stop all running containers
docker stop $(docker ps -q)

# Remove stopped containers
docker container prune
4Set container memory limits

Prevent containers from consuming too much memory:

bash
# Limit memory when running
docker run -m 512m --memory-swap 1g <image>

# In docker-compose.yml
services:
  app:
    deploy:
      resources:
        limits:
          memory: 512M
        reservations:
          memory: 256M

This prevents runaway memory usage.

5Check for OOM kills

See if containers were killed by OOM:

bash
# Check system logs
dmesg | grep -i "oom\|killed"

# Check Docker events
docker events --filter type=container --filter event=oom

# Inspect specific container
docker inspect <container_name> | grep -i oom

OOM kills indicate memory pressure.

6Increase available memory

If the system genuinely needs more memory:

bash
# Add swap space (temporary)
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# For Docker Desktop: Settings > Resources > Memory
# Increase the slider and apply changes

Consider adding more RAM to the host system.

Advanced notes

Docker Desktop Limits: By default, Docker Desktop allocates limited memory. On macOS/Windows, go to Settings > Resources > Advanced and increase memory allocation.

Overcommit Settings: Linux memory overcommit can affect container creation:

bash
cat /proc/sys/vm/overcommit_memory
# 0 = heuristic, 1 = always, 2 = never

Memory Reservation vs Limit: Reservation is soft (guaranteed minimum), limit is hard (cannot exceed). Use both for predictable behavior.

Kubernetes: In K8s environments, check pod resource requests/limits and node allocatable resources.

Frequently asked questions

What does "ENOMEM" mean?
This error occurs when the Linux kernel cannot allocate memory for a new container process. The system may be out of physical RAM, swap space, or hitting cgroup memory limits. Docker containers share the host kernel and memory, so host memory pressure directly affects container creation.
How do I fix "ENOMEM"?
The system does not have enough memory to start the container. Free up memory by stopping unused containers, increasing system RAM, or adjusting container memory limits.
What causes "ENOMEM"?
Host system is out of available memory Too many containers running simultaneously Existing containers consuming excessive memory
Is the "ENOMEM" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading