1.创建目录,并赋予权限
data, logs, conf
mkdir {data,logs,conf}
chmod -R 777 /opt/develop/redis
2.切换到conf目录下,从网上下载redis配置文件
wget http://download.redis.io/redis-stable/redis.conf
3.修改配置文件文章来源:https://www.toymoban.com/news/detail-797471.html
# 开启远程连接
bind 0.0.0.0
tcp-backlog 511
timeout 0
tcp-keepalive 300
supervised no
loglevel notice
databases 16
always-show-logo yes
save ""
requirepass your_redis_password
# 开启aof模式
appendonly yes
maxmemory 500mb
maxmemory-policy volatile-lru
protected-mode yes
4.编写docker-compose.yml文件文章来源地址https://www.toymoban.com/news/detail-797471.html
version: '3.3'
services:
redis:
container_name: redis
image: redis:6.0.6
restart: 'no'
ports:
- 6379:6379
privileged: true
command: redis-server /etc/redis/redis.conf --appendonly yes
volumes:
- $PWD/data:/data:rw
- $PWD/conf/redis.conf:/etc/redis/redis.conf:rw
到了这里,关于docker-compose安装redis的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!