Docker安装Redis

查询redis

执行命令“docker search redis”

C:\Users\guoyu.huang>docker search redis
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
redis                            Redis is an open source key-value store that…   7070                [OK]
bitnami/redis                    Bitnami Redis Docker Image                      117                                     [OK]
sameersbn/redis                                                                  75                                      [OK]
grokzen/redis-cluster            Redis cluster 3.0, 3.2, 4.0 & 5.0               51
kubeguide/redis-master           redis-master with "Hello World!"                29
rediscommander/redis-commander   Alpine image for redis-commander - Redis man…   26                                      [OK]
  • NAME:名称
  • DESCRIPTION:描述
  • STARS:关注度
  • OFFICIAL: 官方
  • AUTOMATED:自动化

带条件搜索

  • 显示官方,语法:docker search [包名] --filter “is-official=true”
C:\Users\guoyu.huang>docker search redis --filter "is-official=true"
NAME                DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
redis               Redis is an open source key-value store that…   7070                [OK]

到官网 http://hub.docker.com,可以查看更多详情

下载Reids

执行命令“docker pull redis”

C:\Users\guoyu.huang>docker pull redis
Using default tag: latest
latest: Pulling from library/redis
fc7181108d40: Pull complete
3e0ac67cad82: Pull complete
a13e0bc380b8: Pull complete
8ee52187e0e1: Pull complete
7293d7cbacc4: Pull complete
1cf7eba39aba: Pull complete
Digest: sha256:fa91121e1a7ed536b960e457ed14625b00df97249b8b32d78cf945bc5be10d19
Status: Downloaded newer image for redis:latest

删除已有的Redis,改装5.0版本

删除指令“docker rmi 镜像名称”

docker rmi redis

下载redis 5.0版本

C:\Users\guoyu.huang>docker pull redis:5.0
5.0: Pulling from library/redis
fc7181108d40: Pull complete
3e0ac67cad82: Pull complete
a13e0bc380b8: Pull complete
8ee52187e0e1: Pull complete
7293d7cbacc4: Pull complete
1cf7eba39aba: Pull complete
Digest: sha256:fa91121e1a7ed536b960e457ed14625b00df97249b8b32d78cf945bc5be10d19
Status: Downloaded newer image for redis:5.0

C:\Users\guoyu.huang>docker images redis
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               5.0                 bb0ab8a99fe6        2 days ago          95MB

映射端口运行Reids

执行语句:docker run -d --name myredis -p6379:6379 -v /d/docker-data/redis:/data redis:5.0

参数说明:

-d —— 后台运行
–name —— 实例运行后的名字 myredis
-p6379:6379 —— 端口映射,冒号前面是windows下的端口,后面是虚拟机的端口
-v /d/docker-data/redis:/data —— 保存数据的位置。
d:\docker-data\redis 前面是windows下的实际保存数据目录

/data 虚拟机内的目录

持久化配置

执行语句:docker run -d --name myredis -p6379:6379 -v /d/docker-data/redis:/data redis:5.0 redis-server --appendonly yes

你可能感兴趣的:(Docker安装Redis)