# docker: Error response from daemon: OCI runtime create failed: cgroup memory limit exceeded for process init

- **ID:** `docker/cgroup-memory-limit-exceeded-for-process`
- **Domain:** docker
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The container's memory limit set via --memory or docker-compose mem_limit is too low for the initial process allocation, causing the OOM killer to terminate the container immediately on start.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Docker 20.10.23 | active | — | — |
| Docker 24.0.7 | active | — | — |
| containerd 1.6.22 | active | — | — |

## Workarounds

1. **Check the container's baseline memory usage by running it without memory limits temporarily using 'docker run --rm <image> free -m' or 'docker stats', then set --memory to at least 1.5x that value. For example, if baseline is 200MB, use '--memory=300m'.** (90% success)
   ```
   Check the container's baseline memory usage by running it without memory limits temporarily using 'docker run --rm <image> free -m' or 'docker stats', then set --memory to at least 1.5x that value. For example, if baseline is 200MB, use '--memory=300m'.
   ```
2. **If using docker-compose, add 'mem_limit: 512m' or higher in the service definition, and also set 'mem_reservation: 256m' to ensure minimum memory availability.** (85% success)
   ```
   If using docker-compose, add 'mem_limit: 512m' or higher in the service definition, and also set 'mem_reservation: 256m' to ensure minimum memory availability.
   ```
3. **For containers with high memory spikes on startup (e.g., Java apps), use '--memory-swap' to allow swap space. Example: 'docker run --memory=256m --memory-swap=512m <image>'.** (80% success)
   ```
   For containers with high memory spikes on startup (e.g., Java apps), use '--memory-swap' to allow swap space. Example: 'docker run --memory=256m --memory-swap=512m <image>'.
   ```

## Dead Ends

- **** — If the container's process requires more memory than the increased limit (e.g., 256MB for a Node.js app), a small increment may still be insufficient, causing the same error. (60% fail)
- **** — While this avoids the error, it removes resource constraints, potentially causing host instability if the container consumes excessive memory. (30% fail)
- **** — The error occurs at runtime initialization, not during build; the base image size does not affect the process's memory allocation at start time. (80% fail)
