docker-compose搭建redis集群
Dockerfile文件:
FROM redis
COPY redis.conf /redis/redis.conf
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
RUN chmod 777 /redis/redis.conf
EXPOSE 6381
EXPOSE 16381
CMD [ "redis-server", "/redis/redis.conf" ]
docker-compose.yml文件:
version: '2'
services:
redis-slave1:
build: ./slave1
ports:
- 6381:6381
- 16381:16381
network_mode: "host"
restart: always
redis-slave2:
build: ./slave2
ports:
- 6382:6382
- 16382:16382
network_mode: "host"
restart: always