CPU and RAM limit

You can limit CPU and RAM to a container by using the Deploy setting,

Set Limit

The docker container cannot use MORE than the limit set

 services:
   container:
    deploy:
      resources:
        limits:
          cpus: ${CPU_LIMIT:-1}
          memory: ${MEM_LIMIT:-100M}

Set Reservation

These resources are kept available for the container

 services:
   container:
    deploy:
      resources:
        reservations:
          cpus: ${CPU_RES:-1}
          memory: ${MEM_RES:-100M}

You can use reservations and limits together

Last updated