Docker Installation of Redis
Redis is an open-source, network-capable, in-memory, log-based, key-value NoSQL database written in ANSI C, with support for persistence and APIs in multiple languages.
1. Check Available Redis Versions
Visit the Redis image repository address: https://hub.docker.com/_/redis?tab=tags.
You can view other versions of Redis by sorting, with the default being the latest version redis:latest.
You can also find other versions you want from the dropdown list:
Additionally, we can use the docker search redis
command to view available versions:
$ docker search redis
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
redis Redis is an open source ... 2321 [OK]
sameersbn/redis 32 [OK]
torusware/speedus-redis Always updated official ... 29 [OK]
bitnami/redis Bitnami Redis Docker Image 22 [OK]
anapsix/redis 11MB Redis server image ... 6 [OK]
webhippie/redis Docker images for redis 4 [OK]
clue/redis-benchmark A minimal docker image t... 3 [OK]
williamyeh/redis Redis image for Docker 3 [OK]
unblibraries/redis Leverages phusion/baseim... 2 [OK]
greytip/redis redis 3.0.3 1 [OK]
servivum/redis Redis Docker Image 1 [OK]
...
2. Pull the Latest Redis Image
Here we pull the official latest version of the image:
$ docker pull redis:latest
3. Check Local Images
Use the following command to see if redis is installed:
$ docker images
From the image above, we can see that we have installed the latest version (latest) of the redis image.
4. Run the Container
After installation, we can use the following command to run the redis container:
$ docker run -itd --name redis-test -p 6379:6379 redis
Parameter explanation:
- -p 6379:6379: Maps the container's 6379 port to the host's 6379 port. External access to Redis services can be directly via the host IP:6379.
5. Installation Successful
Finally, we can view the container's running information using the docker ps command:
Next, we connect and test the redis service using redis-cli.
$ docker exec -it redis-test /bin/bash