Run with resource limits

Limit container to 512MB RAM and half a CPU core

docker run --memory=512m --cpus=0.5 --oom-kill-disable=false myapp

tool
docker46 commands
tags
dockerperformance

More docker commands

  • docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}'

    One-shot CPU and memory snapshot for all containers

  • docker image prune -f

    Remove all <none>:<none> dangling images

  • docker system prune -a --volumes -f

    Remove stopped containers, unused images, networks, volumes

  • docker cp <container>:/app/config.yaml ./local-config.yaml

    Extract a single file from a running or stopped container

  • docker compose up -d --build --remove-orphans

    Rebuild and start services, remove containers not in compose file

all 46 docker commands