DockerHub官方Redis镜像:https://hub.docker.com/_/redis
使用说明(截图)如下:
参照官方redis.conf,具体修改如下:
(1)注释掉bind 127.0.0.1(外网访问)
(2)添加daemonize no(解决启动报错)
(3)修改protected-mode yes->no(外网访问)
(4)添加requirepass yourpassword(自定义auth密码)
FROM redis
MAINTAINER [email protected]
COPY redis.conf /usr/local/etc/redis/redis.conf
EXPOSE 6379
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
#构建镜像(.代表在当前目录Dockerfile)
docker build -t luohq-redis:latest .
#启动docker镜像
docker run -dit --name luohq-redis -p 6379:6379 -v /usr/local/luohq-temp/redis-data:/data luohq-redis:latest#进入docker运行环境
docker exec -it luohq-redis /bin/bash
docker exec -it luohq-redis redis-cli