1. Set the password of Redis when docker starts

docker run --name redis -p 6379:6379 -id redis --requirepass "yourPassword"
Copy the code

2. If you want to change the password of redis:

First check the running condition of docker container

docker ps -a 
Copy the code

Go to the Redis container and run redis-cli

docker exec -it redis /bin/bash
redis-cli
Copy the code

If redis has not set a password, skip this step

Verify permissions first

Otherwise, (error) NOAUTH Authentication Required.

Previous password of authCopy the code

Viewing the Current Password

config get requirepass
Copy the code

Set a new password

config set requirepass 123456
Copy the code