Mac的docker安装redis
1、docker search redis
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
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、添加两个映射目录
mkdir /Users/mac/docker/redis/conf/redis.conf
mkdir /Users/mac/docker/redis/data
4、运行
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、查看日志
或者
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设置密码
#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、测试:
127.0.0.1:6379> set ycz "abc"
OK
127.0.0.1:6379> get ycz
"abc"