Skip to content

No resource limits: container consumes all host resources

Quick summary

Your container has no resource limits — it can use all available CPU and memory, affecting other containers and the host.

Why this happens

  • The container is started without --memory and --cpu limits

  • The docker-compose or Kubernetes manifest does not specify resource requests and limits

  • Resource limits were removed during debugging and not restored

Minimal example

✗ Broken code
# docker-compose.yml
services:
  app:
    image: myapp:latest
    # no resource limits — can consume all host resources
✓ Fixed code
# docker-compose.yml
services:
  app:
    image: myapp:latest
    mem_limit: 512m
    cpus: 1.0
    # or in Kubernetes:
    # resources:
    #   requests: { memory: '256Mi', cpu: '500m' }
    #   limits: { memory: '512Mi', cpu: '1000m' }

Adding memory and CPU limits ensures the container cannot consume more than its share, protecting other services on the host.

How to diagnose

  • Check the container configuration for resource limits with docker inspect

  • Monitor host resource usage to identify containers consuming excessive resources

  • Review the docker-compose or Kubernetes manifest for missing resource specifications

How to fix

  • Add memory and CPU limits to the container configuration

  • Set resource requests and limits in the Kubernetes deployment manifest

  • Use docker stats to determine appropriate limits based on actual usage

How to prevent

  • Always set resource limits on containers in production to prevent resource starvation

  • Monitor resource usage and adjust limits based on actual consumption patterns

Related Resources

Related Glossary

Related Lessons

← Back to language