Note: docker installs redis

Keywords: Redis Docker Database CentOS

search
[root@lrz ~]# docker search redis
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
redis                            Redis is an open source key-value store that...   7733                [OK]
bitnami/redis                    Bitnami Redis Docker Image                      137                                     [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...   32                                      [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...   20
oliver006/redis_exporter          Prometheus Exporter for Redis Metrics. Supp...   18
redislabs/redisearch             Redis With the RedisSearch module pre-loaded...   17
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               8                                       [OK]
arm64v8/redis                    Redis is an open source key-value store that...   7
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

Pull up

If no version is specified, the latest

[root@lrz ~]# docker pull redis:5.0.6
5.0.6: Pulling from library/redis
8d691f585fa8: Pull complete
8ccd02d17190: Pull complete
4719eb1815f2: Pull complete
200531706a7d: Pull complete
eed7c26916cf: Pull complete
e1285fcc6a46: Pull complete
Digest: sha256:34a7ad7d39665763948118fc64d708c6b26f6ba9f88a042f0b2fe21804dff009
Status: Downloaded newer image for redis:5.0.6
Create redis mount directory
[root@lrz ~]# mkdir -p /root/redis/data /root/redis/conf
[root@lrz ~]# ll /root/redis/
total 8
drwxr-xr-x 2 root root 4096 Jan 20 11:00 conf
drwxr-xr-x 2 root root 4096 Jan 20 11:00 data

Create the file redis.conf in the / root/redis/conf directory
touch /root/redis/conf/redis.conf
[root@lrz ~]# touch /root/redis/conf/redis.conf
[root@lrz ~]# ll /root/redis/conf/
total 0
-rw-r--r-- 1 root root 0 Jan 20 11:02 redis.conf

Download official websitehttp://download.redis.io/redis-stable/redis.conf
modify

bind 127.0.0.1 #Note out this part. This is to restrict redis to local access only
protected-mode no #Default yes, turn on protection mode and restrict to local access
daemonize no #The default no, changed to yes, means to start in the way of daemons and run in the background. Unless the kill process is changed to yes, it will fail to start redis in the way of configuration file
databases 16 #Number of databases (optional). I modified this to see if it works..
dir ./ #Enter the local redis database storage folder (optional)
appendonly yes #redis persistence (optional)

start-up
docker run -d --name redis -p 6379:6379 -v /root/redis/conf/redis.conf:/redis.conf -v /root/redis/data:/data redis:5.0.6 redis-server --appendonly yes
[root@lrz ~]# docker run -d --name redis -p 6379:6379 -v /root/redis/conf/redis.conf:/redis.conf -v /root/redis/data:/data redis:5.0.6 redis-server --appendonly yes
c86d46f96f34d1640dacc7f17be569b505caede334b9ff1ded4532e03faff10f

-d background operation
-p port mapped to host port
-v mount the host directory to the container's directory
Redis server -- appendonly yes: execute the redis server startup command in the container, and open the redis persistence configuration

Check whether there is data in / root/redis/data
[root@lrz ~]# ll /root/redis/data/
total 0
-rw-r--r-- 1 polkitd input 0 Jan 20 11:04 appendonly.aof

Published 9 original articles, won praise 2, visitors 221
Private letter follow

Posted by Clintonio on Mon, 20 Jan 2020 06:48:04 -0800