Home  >  Article  >  Database  >  How to install Redis with Docker

How to install Redis with Docker

PHPz
PHPzforward
2023-05-31 12:34:181130browse

Docker Install Redis

Redis is an open source NoSQL database written in ANSI C language, supports network, can be memory-based and persistent, log-type, Key-Value, and provides multiple languages. API.

1. View available Redis versions

You can view other versions of Redis through Sort by. The default is the latest version redis:latest.

How to install Redis with Docker

You can also find other versions you want in the drop-down list:

How to install Redis with Docker

In addition, we can Use the docker search redis command to view the 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. Get the latest version of the Redis image

Here we pull the official latest version of the image:

$ docker pull redis:latest

How to install Redis with Docker

3. Check the local image

Use the following command to check whether redis has been installed:

$ docker images

How to install Redis with Docker

In the picture above You can see that we have installed the latest version of the redis image.

4. Run the container

After the installation is complete, we can use the following command to run the redis container:

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

Parameter description:

  • -p 6379:6379: Map the 6379 port of the container service to the 6379 port of the host. The Redis service can be accessed from the outside directly through the host IP:6379.

How to install Redis with Docker

5. Installation successful

Finally we can view the running information of the container through the docker ps command:

How to install Redis with Docker

Then we test the use of the redis service through the redis-cli connection.

$ docker exec -it redis-test /bin/bash

How to install Redis with Docker

The above is the detailed content of How to install Redis with Docker. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete