Resource Requirements

  • docker run has many options, service create has different options
  • Set at service create/update, but are controlled per-container
  • Set for CPU and memory, reserving and limiting
  • Maximum given to container
    • --limit-cpu .5
    • --limit-memory 256M
  • Beware of OOME (with or without limits)
    • when memory resource limit is hit, container will be killed and rescheduled
  • Minimum free needed to schedule container (Swarm keeps track)
    • --reserve-cpu .5
    • --reserve-memory 256M

Examples

  • Reserve cpu and memory
    • docker service create --reserve-memory 800M --reserve-cpu 1 mysql
  • Limit cpu and memory
    • docker service create --limit-memory 150M --limit-cpu .25 nginx
  • Service update is the same
  • Remove them with update to 0
    • docker service update --limit-memory 0 --limit-cpu 0 myservice

Resource Requirements in Stack Files

version: "3.1"
services:
  database:
    image: mysql
    deploy:
      resources:
        limits:
          cpus: '1'
          memory: 1G
        reservations:
          cpus: '0.5'
          memory: 500M

results matching ""

    No results matching ""