Docker swarm custom scheduler We have a 6 node docker swarm running and we often see bad scheduling (clean inbalance) happening.

I've researched this subject, and it seems docker swarm as standalone used to allow a way to choose different strategies to its scheduler, but since swarm was integrated into docker it only supports the spread strategy. In our case, since we are very memory intensive, we would benefit from only considering memory and not CPU/#containers as a metric.

How could we achieve this?
The scheduler itself is not swappable. However, you can set memory constraints and reservations on containers in your service:

version: '3'
services:
  redis:
    image: redis:alpine
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 50M
        reservations:
          cpus: '0.25'
          memory: 20M


The constraint will kill the container if it exceeds the limit even if the host has more memory available. The reservation will ensure that amount of memory on the host is available for the container.