Search code examples
dockerdocker-swarmdocker-machinedocker-swarm-modedocker-stack

Docker Swarm Mode Error: Joining Two Workers To One Manager


I'm having difficulty setting up a Docker Swarm with two workers and one manager. Everything works fine until I add the second worker. After adding the second worker, the first worker's daemon enters some sort of error state where a simple docker version yields

enter image description here

Also, I am using a Stack YAML to start three Redis services.

Stack.yaml

version: '3.4'

services:
  redis-master:
    image: 'bitnami/redis:5.0.2'
    ports:
      - '6379:6379'
    environment:
      - REDIS_REPLICATION_MODE=master 
      - REDIS_PASSWORD=f7paul12-d571-4701-9c55-64vanacecDyK
    deploy:
      mode: global
      restart_policy:
        condition: any
    volumes: 
      - 'redis:/opt/bitnami/redis/etc/'

  redis-replica:
    image: 'bitnami/redis:5.0.2'
    ports:
      - '6379'
    depends_on:
      - redis-master
    environment:
      - REDIS_REPLICATION_MODE=slave
      - REDIS_MASTER_HOST=redis-master
      - REDIS_MASTER_PORT_NUMBER=6379
      - REDIS_MASTER_PASSWORD=f7paul12-d571-4701-9c55-64vanacecDyK
      - REDIS_PASSWORD=f7paul12-d571-4701-9c55-64vanacecDyK
    deploy:
      mode: replicated
      replicas: 6
      update_config:
        parallelism: 1
        delay: 20s
      restart_policy:
        condition: any

  redis-sentinel:
    image: 'bitnami/redis:5.0.2'
    ports:
      - '16379'
    depends_on:
      - redis-master
      - redis-replica
    entrypoint: |
      bash -c 'bash -s <<EOF
      "/bin/bash" -c "cat <<EOF > /opt/bitnami/redis/etc/sentinel.conf
      port 16379
      dir /tmp
      sentinel monitor master-node redis-master 6379 2
      sentinel down-after-milliseconds master-node 5000
      sentinel parallel-syncs master-node 1
      sentinel failover-timeout master-node 5000
      sentinel auth-pass master-node f7paul12-d571-4701-9c55-64vanacecDyK
      sentinel announce-ip redis-sentinel
      sentinel announce-port 16379
      EOF"     
      "/bin/bash" -c "redis-sentinel /opt/bitnami/redis/etc/sentinel.conf"    
      EOF'
    deploy:
      mode: global
      restart_policy:
        condition: any
volumes:
  redis:
    driver: external
    driver_opts:
      type: 'none'
      o: 'bind'
      device: '/c/redis/'

I am running Docker CE 18.09.0 on Windows Server 2016 (the EE had the same problem) Also, all of my worker nodes are on the Windows platform, using Linux containers. (My manager node is the same, but uses Windows containers because of issue #3031)

Is setting up a mutinode swarm even supported in exclusive Windows environments? How can this cluster be set up using the environment listed above?


Solution

  • Swarm is supported on windows but you shouldn't be using docker ce and linux containers on windows server. Docker ce for windows uses hyperv linux virtual machine and win server 2016 had a lot of issuses with hyperv networking.

    I was also trying win server 2016 with docker ee in swarm but due to multiple limitations I abandoned that idea until newer version of windows server come along.

    You should try either windows server that is abover 1803 where Microsoft finally allowed exposing ports to host. Therefore I'd recommend for you using windows server core 1803 or 1809, or using windows server 2019 (which is 1809)

    And switch to windows containers on windows. For linux containers use linux host. Will save you a lot of headaches.