Docker installs redis, redis cli test connection and python API test connection.


Docker installing redis

Pull image, start

Pull image

docker pull redis

View existing image

docker images

Start docker

docker run -itd --name redis -p 6379:6379 redis

View the container status of docker running

docker ps

Test use

Test the connection inside the container

docker exec -it redis /bin/bash

After entering the container

[email protected]:/data# redis-cli> set username jabin
OK> get username

Test the connection outside the container

The redis container is bound to the6379Therefore, it can be considered that redis is running on the6379Port.

Using redis cli connection

If the host computer is installed withredis-cli, you can use theredis-cliTest.

➜  Desktop redis-cli -h -p 6379> get username

Using Python API connection

import redis

r = redis.StrictRedis(host='', port=6379)

print(str(r.get("username"), encoding="utf-8"))