1、拉取镜像
docker pull redis
2、运行容器
docker run -p 6379:6379 --name redis -v /mydata/redis/redis.conf:/etc/redis/redis.conf -v /mydata/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes
docker run -p 6379:6379 --name redis -v /mydata/redis/redis.conf:/etc/redis/redis.conf -v /mydata/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes --requirepass xianw
3、设置密码
docker exec -it redis /bin/bash
cd /usr/local/bin
redis-cli
config get requirepass
config set requirepass 密码
auth 密码
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/fd6c06b263ba6c3962b824e0a9569eb9.png)