1、拉取redis镜像
bash
docker pull redis
2、编辑redis的conf目录和data目录
bash
mkdir -p /home/sunyuhua/docker/redis/conf
bash
vi redis.conf
填写以下内容
bash
bind 0.0.0.0
protected-mode no
appendonly yes
requirepass 123456
bash
mkdir -p /home/sunyuhua/docker/redis/data
3、启动reids
bash
docker run --restart=always --name redis -p 6379:6379 -v /home/sunyuhua/docker/redis/data:/data -v /home/sunyuhua/docker/redis/conf/redis.conf:/etc/redis/redis.conf -d redis redis-server /etc/redis/redis.conf
4、验证redis
bash
docker exec -it redis redis-cli
bash
auth 123456
bash
set a 1