Docker安装Redis

Posted 闲人鹤

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker安装Redis相关的知识,希望对你有一定的参考价值。

参考资料:https://www.runoob.com/docker/docker-install-redis.html

 

1. 查找Docker Hub上的Redis镜像

  命令:docker search redis

[root@localhost docker]# docker search redis
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
redis                            Redis is an open source key-value store that…   7788                [OK]                
bitnami/redis                    Bitnami Redis Docker Image                      136                                     [OK]
sameersbn/redis                                                                  79                                      [OK]
grokzen/redis-cluster            Redis cluster 3.0, 3.2, 4.0 & 5.0               62                                      
rediscommander/redis-commander   Alpine image for redis-commander - Redis man…   33                                      [OK]
kubeguide/redis-master           redis-master with "Hello World!"                31                                      
redislabs/redis                  Clustered in-memory database engine compatib…   24                                      
redislabs/redisearch             Redis With the RedisSearch module pre-loaded…   20                                      
arm32v7/redis                    Redis is an open source key-value store that…   20                                      
oliver006/redis_exporter          Prometheus Exporter for Redis Metrics. Supp…   18                                      
webhippie/redis                  Docker images for Redis                         10                                      [OK]
insready/redis-stat              Docker image for the real-time Redis monitor…   9                                       [OK]
s7anley/redis-sentinel-docker    Redis Sentinel                                  9                                       [OK]
bitnami/redis-sentinel           Bitnami Docker Image for Redis Sentinel         9                                       [OK]
redislabs/redisgraph             A graph database module for Redis               9                                       [OK]
arm64v8/redis                    Redis is an open source key-value store that…   8                                       
redislabs/redismod               An automated build of redismod - latest Redi…   6                                       [OK]
centos/redis-32-centos7          Redis in-memory data structure store, used a…   4                                       
frodenas/redis                   A Docker Image for Redis                        2                                       [OK]
circleci/redis                   CircleCI images for Redis                       2                                       [OK]
runnable/redis-stunnel           stunnel to redis provided by linking contain…   1                                       [OK]
wodby/redis                      Redis container image with orchestration        1                                       [OK]
tiredofit/redis                  Redis Server w/ Zabbix monitoring and S6 Ove…   1                                       [OK]
xetamus/redis-resource           forked redis-resource                           0                                       [OK]
cflondonservices/redis           Docker image for running redis                  0                                       

 

2. 拉取官方的镜像,要最新版

  命令:docker pull redis:latest

[root@localhost docker]# docker pull redis:latest
latest: Pulling from library/redis
bc51dd8edc1b: Pull complete 
37d80eb324ee: Pull complete 
392b7748dfaf: Pull complete 
48df82c3534d: Pull complete 
2ec2bb0b4b0e: Pull complete 
1302bce0b2cb: Pull complete 
Digest: sha256:7b84b346c01e5a8d204a5bb30d4521bcc3a8535bbf90c660b8595fad248eae82
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest

 

3. 等待下载完成后,我们就可以在本地镜像列表里查到REPOSITORY为redis,版本为latest的镜像

[root@192 docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               latest              44d36d2c2374        6 days ago          98.2MB

 

4. 运行镜像

  命令:docker run -itd --name zh-redis -p 6379:6379 redis

[root@192 docker]# docker run -itd --name zh-redis -p 6379:6379 redis
f7ac74b4928e7c06c55ae90d2ff2cbb79875a70ffbb735896643f31e74aeacdd

  命令说明:

  --name : 镜像的名称  

  -p 3306:3306:将容器的 3306 端口映射到主机的 3306 端口。

  

5. 查看容器启动情况

[root@192 docker]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
f7ac74b4928e        redis               "docker-entrypoint.s…"   12 seconds ago      Up 11 seconds       0.0.0.0:6379->6379/tcp   zh-redis

 

6. 进入容器并操作Redis

[root@192 docker]# docker exec -it zh-redis /bin/bash
root@f7ac74b4928e:/data# redis-cli
127.0.0.1:6379> set test 1
OK

 

以上是关于Docker安装Redis的主要内容,如果未能解决你的问题,请参考以下文章

linux中怎么docker安装redis

如何在docker中安装redis

docker 安装 redis

Docker安装redis

mac系统Docker安装Redis教程

docker 安装redis