Docker快速安装redis

查询镜像

docker search redis

结果:

[root@VM_0_2_centos ~]# docker search redis
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
redis                            Redis is an open source key-value store that…   7956                [OK]
bitnami/redis                    Bitnami Redis Docker Image                      139                                     [OK]
sameersbn/redis                                                                  79                                      [OK]
grokzen/redis-cluster            Redis cluster 3.0, 3.2, 4.0 & 5.0               64
rediscommander/redis-commander   Alpine image for redis-commander - Redis man…   36                                      [OK]
kubeguide/redis-master           redis-master with "Hello World!"                31
redislabs/redis                  Clustered in-memory database engine compatib…   24
arm32v7/redis                    Redis is an open source key-value store that…   21
oliver006/redis_exporter          Prometheus Exporter for Redis Metrics. Supp…   20
redislabs/redisearch             Redis With the RedisSearch module pre-loaded…   20
bitnami/redis-sentinel           Bitnami Docker Image for Redis Sentinel         12                                      [OK]
webhippie/redis                  Docker images for Redis                         11                                      [OK]
redislabs/redisgraph             A graph database module 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]
arm64v8/redis                    Redis is an open source key-value store that…   8
redislabs/redismod               An automated build of redismod - latest Redi…   7                                       [OK]
centos/redis-32-centos7          Redis in-memory data structure store, used a…   5
circleci/redis                   CircleCI images for Redis                       4                                       [OK]
redislabs/redisinsight           RedisInsight - The GUI for Redis                4
clearlinux/redis                 Redis key-value data structure server with t…   2
tiredofit/redis                  Redis Server w/ Zabbix monitoring and S6 Ove…   1                                       [OK]
wodby/redis                      Redis container image with orchestration        1                                       [OK]
runnable/redis-stunnel           stunnel to redis provided by linking contain…   1                                       [OK]
xetamus/redis-resource           forked redis-resource                           0                                       [OK]
[root@VM_0_2_centos ~]#

拉取镜像

docker pull redis

结果:

[root@VM_0_2_centos ~]# docker pull redis
Using default tag: latest
latest: Pulling from library/redis
68ced04f60ab: Already exists
7ecc253967df: Pull complete
765957bf98d4: Pull complete
91fff01e8fef: Pull complete
76feb725b7e3: Pull complete
75797de34ea7: Pull complete
Digest: sha256:ddf831632db1a51716aa9c2e9b6a52f5035fc6fa98a8a6708f6e83033a49508d
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
[root@VM_0_2_centos ~]#

#配置文件定义

mkdir -p /usr/local/redis/conf && cd /usr/local/redis/conf && wget http://download.redis.io/redis-stable/redis.conf

授权

chmod 775 redis.conf

#查看

docker images

结果:

[root@VM_0_2_centos redis]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
redis                 latest              f0453552d7f2        13 days ago         98.2MB
mysql                 5.7                 84164b03fa2e        3 weeks ago         456MB
truevoly/oracle-12c   latest              21789d4d876f        13 months ago       5.7GB
[root@VM_0_2_centos redis]#

更改配置

vim   /usr/local/redis/conf/redis.conf

注释掉 bind 127.0.0.1
修改 protected-mode no

创建docker容器

docker run -p  6379:6379 --name redis -v $PWD/conf/redis.conf:/etc/redis/redis.conf -v $PWD/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes --requirepass "123456"

#查看容器

docker ps -a

结果:

[root@VM_0_2_centos redis]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND                      CREATED             STATUS              PORTS                                            NAMES
00a17b8e4eb7        redis                 "docker-entrypoint.s…"   26 seconds ago      Up 26 seconds       0.0.0.0:6379->6379/tcp                           redis
6f1c2f5372b5        truevoly/oracle-12c   "/entrypoint.sh "        4 hours ago         Up 4 hours          0.0.0.0:1521->1521/tcp, 0.0.0.0:8080->8080/tcp   orac
d9fe468f1d89        mysql:5.7             "docker-entrypoint.s…"   6 hours ago         Up 4 hours          0.0.0.0:3306->3306/tcp, 33060/tcp                mysql

连接

docker exec -it 00a17b8e4eb7 redis-cli

127.0.0.1:6379> AUTH 123456

说明

本文只做学习参考,如有任何不准确的地方欢迎指正。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值