添加配置,下载默认 redis.conf 文件 http://download.redis.io/redis-stable/redis.conf
redis.conf 文件 拷贝到 redis Dockerfile同级目录
修改 Dockerfile 为
FROM redis:latest
LABEL maintainer="Mahmoud Zalt <[email protected]>"
## For security settings uncomment, make the dir, copy conf, and also start with the conf, to use it
RUN mkdir -p /usr/local/etc/redis
COPY redis.conf /usr/local/etc/redis/redis.conf
VOLUME /data
EXPOSE 6379
CMD ["redis-server", "/usr/local/etc/redis/redis.conf"]
重新构建并启动
docker-compse build redis
docker-compse up -d redis
参考:https://blog.reunicode.com/2018/05/02/22/42/268/