Docker Community Forums

Share and learn in the Docker community.

Redis replication in windows

I have trouble implementing redis replication in windows 10 and windows 2019 servers. I am able to create redis containers using docker-compose as well as docker run commands, however replication is not working as expected.

  1. I am using below docker compose file to create containers.

version: ‘2.4’
Script:

services:
redis-primary:
image: ‘redis:latest’
ports:
- 6379
environment:
- REDIS_REPLICATION_MODE=master
- REDIS_PASSWORD=mypass
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
volumes:
- ‘redis_data:/redis/data’

redis-secondary:
image: ‘redis:latest’
ports:
- 6380
depends_on:
- redis-primary
environment:
- REDIS_REPLICATION_MODE=slave
- REDIS_MASTER_HOST=redis-primary
- REDIS_MASTER_PORT_NUMBER=6379
- REDIS_MASTER_PASSWORD=mypass
- REDIS_PASSWORD=mypass
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL

volumes:
redis_data:
driver: local

  1. I have tried running slaveof after containers are created, but getting below error:

redis-secondary_1 | 1:S 15 Jun 2020 06:36:59.522 * Master is currently unable to PSYNC but should be in the future: -NOMASTERLINK Can’t SYNC while not connected with my master
redis-secondary_1 | 1:S 15 Jun 2020 06:37:00.526 * Connecting to MASTER 127.0.0.1:6379
redis-secondary_1 | 1:S 15 Jun 2020 06:37:00.526 * MASTER <-> REPLICA sync started
redis-secondary_1 | 1:S 15 Jun 2020 06:37:00.526 * Non blocking connect for SYNC fired the event.
redis-secondary_1 | 1:S 15 Jun 2020 06:37:00.526 * Master replied to PING, replication can continue…
redis-secondary_1 | 1:S 15 Jun 2020 06:37:00.527 * Trying a partial resynchronization (request 12454945c9738e73959f27628a14d381c81bfbf3:1).

SYNC with master failed: -NOMASTERLINK Can’t SYNC while not connected with my master

I have also tried creating master,slave containers using docker run commands and redis.conf files with changing port numbers. But it is still throwing same error.

Any help in this regard is appreciated and thanks in advance.