Mac的docker安装redis

Mac的docker安装redis

bash 复制代码
NAME                                DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
redis                               Redis is an open source key-value store that...   12205     [OK]       
redislabs/redisearch                Redis With the RedisSearch module pre-loaded...   56                   
redislabs/redisinsight              RedisInsight - The GUI for Redis                 88                   
redislabs/rebloom                   A probablistic datatypes module for Redis        23                   [OK]
redislabs/redis                     Clustered in-memory database engine compatib...   38                   
redis/redis-stack-server            redis-stack-server installs a Redis server w...   47                   
redislabs/rejson                    RedisJSON - Enhanced JSON data type processi...   53                   
redis/redis-stack                   redis-stack installs a Redis server with add...   59                   
redislabs/redisgraph                A graph database module for Redis                26                   [OK]
redislabs/redismod                  An automated build of redismod - latest Redi...   41                   [OK]
redislabs/redistimeseries           A time series database module for Redis          12                   
redislabs/operator                                                                   7                    
redislabs/operator-internal         This repository contains pre-released versio...   1                    
redislabs/redis-py                                                                   5                    
redislabs/redis-webcli              A tiny Flask app to provide access to Redis ...   3                    [OK]
redislabs/redisgears                An automated build of RedisGears                 4                    
redislabs/k8s-controller-internal                                                    0                    
redislabs/memtier_benchmark         Docker image to run memtier_benchmark            0                    
redislabs/ng-redis-raft             Redis with redis raft module                     0                    
redislabs/k8s-controller                                                             2                    
redislabs/redisai                                                                    5                    
redislabs/olmtest                   Test artefact for OLM CSV                        0                    
bitnami/redis                       Bitnami Redis Docker Image                       259                  [OK]
redislabs/olm-bundle                                                                 0                    
redislabs/redisml                   A Redis module that implements several machi...   3                    [OK]

2、docker pull redis

bash 复制代码
macdeMacBook-Pro:~ mac$ docker pull redis
Using default tag: latest
latest: Pulling from library/redis
faef57eae888: Pull complete 
bb595d48e52d: Pull complete 
d479b54c3bb2: Pull complete 
2044989c541a: Pull complete 
01e4ba5495fa: Pull complete 
ed7a9fd4b0ea: Pull complete 
Digest: sha256:08a82d4bf8a8b4dd94e8f5408cdbad9dd184c1cf311d34176cd3e9972c43f872
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest

What's Next?
  View summary of image vulnerabilities and recommendations → docker scout quickview redis

3、添加两个映射目录

bash 复制代码
mkdir /Users/mac/docker/redis/conf/redis.conf
mkdir /Users/mac/docker/redis/data

4、运行

bash 复制代码
docker run --name redis -p 6379:6379 -v /Users/mac/docker/redis/conf/redis.conf:/etc/redis/redis.conf -v /Users/mac/docker/redis/data:/data -d redis redis-server /etc/redis/redis.conf 

5、查看日志

或者

bash 复制代码
macdeMacBook-Pro:redis mac$ docker logs -f redis
1:C 13 Jul 2023 13:47:33.118 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 13 Jul 2023 13:47:33.118 # Redis version=7.0.12, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 13 Jul 2023 13:47:33.118 # Configuration loaded
1:M 13 Jul 2023 13:47:33.119 * monotonic clock: POSIX clock_gettime
1:M 13 Jul 2023 13:47:33.120 * Running mode=standalone, port=6379.
1:M 13 Jul 2023 13:47:33.120 # Server initialized
1:M 13 Jul 2023 13:47:33.121 * Ready to accept connections
1:M 13 Jul 2023 13:48:07.372 # Possible SECURITY ATTACK detected. It looks like somebody is sending POST or Host: commands to Redis. This is likely due to an attacker attempting to use Cross Protocol Scripting to compromise your Redis instance. Connection aborted.

6、为redis设置密码

bash 复制代码
#1.进入redis的容器
docker exec -it 容器ID bash

cd /usr/local/bin

# redis-cli
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""
127.0.0.1:6379> config set requirepass 123456
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "123456"

7、测试:

bash 复制代码
127.0.0.1:6379> set ycz "abc"
OK
127.0.0.1:6379> get ycz
"abc"
相关推荐
r***11336 分钟前
Redis--模糊查询--方法实例
数据库·redis·缓存
·云扬·34 分钟前
Redis性能测试实战:掌握redis-benchmark工具用法与集群压测技巧
数据库·redis·缓存
2401_8370885038 分钟前
秒杀优化—基于 Redis 完成秒杀下单
数据库·redis·缓存
爬山算法1 小时前
Redis(144)Redis的Cluster的节点通信是如何实现的?
数据库·redis·缓存
q***72191 小时前
PHP使用Redis实战实录2:Redis扩展方法和PHP连接Redis的多种方案
开发语言·redis·php
深蓝电商API1 小时前
Scrapy + Scrapy-Redis 分布式爬虫集群部署(2025 最新版)
redis·分布式·scrapy
r***93482 小时前
【Redis】在Java中以及Spring环境下操作Redis
java·redis·spring
百***48072 小时前
redis连接服务
数据库·redis·bootstrap
EAIReport3 小时前
企业级报表自动化:基于Docker的部署实践
运维·docker·自动化
雨中飘荡的记忆4 小时前
秒杀系统设计与实现
java·redis·lua