Reference:
install docker
- yum install -y docker
- systemctl start docker
- systemctl enable docker
install redis
- docker pull redis:latest
- docker run --name redis -p 6379:6379 -d --restart always redis
- docker ps
check docker images
- docker images
test redis
- docker exec -it redis bash
- redis-cli
- set test "hello world"
- get test
stop docker image (redis)
- docker stop redis
使用密碼認證
- 找出 redis version
- docker images
- IMAGE_ID=<image ID>
- docker image inspect --format '{{json .}}' "$IMAGE_ID"
- 找 REDIS_VERSION=x.x.x
- 下載對應的 redis.conf,放在 /root/redis/redis.conf
- 修改 redis.conf
- requirepass <your_password>
- #bind 127.0.0.1
- docker stop redis
- docker run --name redis -p 6379:6379 -d -v /root/redis:/usr/local/etc/redis --re
start always redis redis-server /usr/local/etc/redis/redis.conf
確認有使用密碼驗證
- docker exec -it redis bash
- redis-cli
- config get requirepass
- (error) NOAUTH Authentication required.
- auth <your_password>
- OK
- config get requirepass
- 1) "requirepass"
- 2) "<your_password>"
沒有留言:
張貼留言