Passive replicas with Docker swarm mode

I’m trying to figure out a proper way to implement active/passive failover between replicas of a service with Docker swarm mode.

The service will hold a valuable in-memory state that cannot be lost, that’s why I need multiple replicas of it. The replicas will internally implement Raft, so that only the replica which is active (“leader”) at a given moment will accept requests from clients.

  • Cannot pip install pymssql from docker container which is running centos6.6
  • Docker wait for web app to start (dependency)
  • what is the use of HOST and NONE network in docker?
  • Source controlling (git) docker-compose.yml
  • Why do my volumes sometime not get mounted in my Docker container when using fig?
  • How do i deploy from GitLab CI to Google Container Engine instance using Docker?
  • (If you’re unfamiliar with Raft: simply put, it is a distributed consensus algorithm, which helps implement active/passive fault-tolerant cluster of replicas. According to Raft, the active replica – the leader – replicates changes in its data to passive replicas – the followers. Only leader accepts requests from clients. If the leader fails, a new leader is elected among the followers).

    As far as I understand, Docker will guarantee that a specified number of replicas are up and running, but it will balance incoming requests among all of the replicas, in the active/active manner.

    How can I tell Docker to route requests only to the active replica, but still guarantee that all replicas are up?

    One option is routing all requests through an additional NGINX container, and updating its rules each time a new leader is elected. But that will be an additional hop, which I’d like to avoid.

    I’m also trying to avoid external/overlapping tools such as consul or kubernetes, in order to keep the solution as simple as possible. (HAProxy is not an option because I need a Linux/Windows portable solution). So currently I’m trying to understand if this can be done with Docker swarm mode alone.

    Another approach I came across is returning a failing health check from passive replicas. It does the trick with kubernetes according to this answer, but I’m not sure it will work with Docker. How does swarm manager interpret failing health checks from task containers?

    I’d appreciate any thought.

  • Docker and MySQL can't connect
  • Docker user defined network gateway timeout
  • Docker multiple entrypoints
  • Sequel Pro with Mysql in Docker
  • standard_init_linux.go:178: exec user process caused “exec format error”
  • Expose Docker Ports and Access with DNS for easier Ansible-Access
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.