docker安装redis

阅读更多

1、➜  ~ docker search redis
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
redis                            Redis is an open source key-value store that…   7102                [OK]
bitnami/redis                    Bitnami Redis Docker Image                      119                                     [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]
redislabs/redis                  Clustered in-memory database engine compatib…   21
arm32v7/redis                    Redis is an open source key-value store that…   16
redislabs/redisearch             Redis With the RedisSearch module pre-loaded…   15
oliver006/redis_exporter          Prometheus Exporter for Redis Metrics. Supp…   11
webhippie/redis                  Docker images for Redis                         10                                      [OK]
s7anley/redis-sentinel-docker    Redis Sentinel                                  8                                       [OK]
insready/redis-stat              Docker image for the real-time Redis monitor…   7                                       [OK]
arm64v8/redis                    Redis is an open source key-value store that…   6
bitnami/redis-sentinel           Bitnami Docker Image for Redis Sentinel         5                                       [OK]
redislabs/redisgraph             A graph database module for Redis               5                                       [OK]
centos/redis-32-centos7          Redis in-memory data structure store, used a…   4
redislabs/redismod               An automated build of redismod - latest Redi…   3                                       [OK]
circleci/redis                   CircleCI images for Redis                       2                                       [OK]
frodenas/redis                   A Docker Image for Redis                        2                                       [OK]
wodby/redis                      Redis container image with orchestration        2                                       [OK]
tiredofit/redis                  Redis Server w/ Zabbix monitoring and S6 Ove…   1                                       [OK]
runnable/redis-stunnel           stunnel to redis provided by linking contain…   1                                       [OK]
xetamus/redis-resource           forked redis-resource                           0                                       [OK]
cflondonservices/redis           Docker image for running redis                  0

2、docker pull redis 会自动拉取最新版本的redis

3、docker run --name redis1 -p 6379:6379  -d redis  //指定一个端口,创建 运行 一个 redis1容器。

4、docker exec -it redis1 bash  //进入容器中

到此就可以基本测试了;如果需要挂自己的配置则需要以下操作

 

5、创建目录和配置文件redis.conf
mkdir /develop
mkdir /develop/redis
mkdir /develop/redis/conf
mkdir /develop/redis/data
创建redis.conf配置文件
touch /develop/redis/conf/redis.conf
切记redis.conf中注释掉:#daemonize yes 否则无法启动容器

docker run -p 6379:6379 --name redis-latest -v /usr/local/redis/conf:/etc/redis/redis.conf -d redis:latest redis-server /etc/redis/redis.conf

--privileged=true:容器内的root拥有真正root权限,否则容器内root只是外部普通用户权限
-v /develop/redis/conf/redis.conf:/etc/redis/redis.conf:映射配置文件
-v /develop/redis/data:/data:映射数据目录
redis-server /etc/redis/redis.conf:指定配置文件启动redis-server进程
--appendonly yes:开启数据持久化


--------------------- 
作者:yjph83 
来源:CSDN 
原文:https://blog.csdn.net/yjph83/article/details/96115623 
版权声明:本文为博主原创文章,转载请附上博文链接!

你可能感兴趣的:(docker,redis)