1、进入redis容器
MacBook-Pro:bin Tseng$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5fead6f46506 portainer/portainer "/portainer" 6 months ago Up 8 minutes 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp portainer
ae4b474b3b13 redis "docker-entrypoint.s…" 6 months ago Up 6 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis
56983a45bdc4 mysql "docker-entrypoint.s…" 6 months ago Up 6 minutes 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
MacBook-Pro:bin Tseng$ docker exec -it ae4b bash
2、进入redis目录
root@ae4b474b3b13:/data# cd /usr/local/bin/
3、运行redis命令
root@ae4b474b3b13:/usr/local/bin# redis-cli
4、查看现有的redis密码
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""
127.0.0.1:6379>
5、设置redis密码
127.0.0.1:6379> config set requirepass 123456
OK
127.0.0.1:6379>
6、连接测试