拉取一个redis镜像,要知道版本号,我的时5.0.4。这个跟关键,涉及到之后使用的redis.conf,要使用相同版本的。
redis.conf下载地址:http://download.redis.io/releases/
docker-compose.yml:
version: '3.0'
services:
redis:
image: registry.cn-hangzhou.aliyuncs.com/safebox/redis:5.0.4
container_name: redis
ports:
- "6379:6379"
volumes:
- ./redis:/etc/redis
tty: true
redis.conf:
bind 172.0.0.1
改成
bind 0.0.0.0
从而允许远程访问。
如果要使用密码
修改:
#requirepass foobared
为
requirepass 123456<你的密码>