编写yaml文件
version: '3.4'
services:
master:
image: redis
container_name: redis-master
restart: always
command: redis-server --port 6379 --requirepass 1234
# network_mode: "host"
ports:
- 6379:6379
slave1:
image: redis
container_name: redis-slave-1
restart: always
command: redis-server --slaveof 192.168.16.104 6379 --port 6380 --requirepass 1234 --masterauth 1234
# network_mode: "host"
ports:
- 6380:6380
slave2:
image: redis
container_name: redis-slave-2
restart: always
command: redis-server --slaveof 192.168.16.104 6379 --port 6381 --requirepass 1234 --masterauth 1234
# network_mode: "host"
ports:
- 6381:6381