创建 network
1
docker network create --driver bridge --subnet 172.22.0.0/16 --gateway 172.22.0.1 op_net
创建 redis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42version: '3.6'
services:
redis-1:
image: redis
restart: always
hostname: redis-1
container_name: redis-1
ports:
- 6379:6379
networks:
default:
ipv4_address: 172.22.0.26
redis-2:
image: redis
restart: always
hostname: redis-2
container_name: redis-2
ports:
- 6380:6379
command: redis-server --slaveof redis-1 6379
networks:
default:
ipv4_address: 172.22.0.27
redis-3:
image: redis
restart: always
hostname: redis-3
container_name: redis-3
ports:
- 6381:6379
command: redis-server --slaveof redis-1 6379
networks:
default:
ipv4_address: 172.22.0.28
networks:
default:
external:
name: op_net启动 Redis 集群
1
docker-compose -f redis.yml up -d
基于 Docker 搭建 Redis 集群
小礼物走一走,来 Github 关注我