下載redis.conf配置
下載地址:
http://download.redis.io/redis-stable/redis.conf
拉取docker鏡像
docker pull redis:6.0.6
使用weget下載redis.conf
cd /usr/local/redis
wget http://download.redis.io/redis-stable/redis.conf
修改redis.conf配置
protected-mode no 關(guān)閉保護(hù)模式寂拆,負(fù)責(zé)不能外網(wǎng)訪問
requirepass 123456 設(shè)置密碼
daemonize yes配置是否后臺(tái)啟動(dòng)
bind 127.0.0.1綁定IP奢米。聽說這里有點(diǎn)坑,我是沒發(fā)現(xiàn)
dir /*** 數(shù)據(jù)存放得目錄 我是在usr/local/redis下面新鍵了一個(gè)文件夾放數(shù)據(jù)叫ddb mkdir ddb
appendonly 是否支持持久化數(shù)據(jù) yes/no
運(yùn)行docker
docker run -d -name myRedis -p 6379:6379 -v /var/redis/data:/data -v /usr/local/redis.conf:/etc/redis/redis.conf --restart=always redis:6.0.6 redis-server /etc/redis/redis.conf
docker-compose.yml
version: "3"
services:
redis:
image: redis:6.0.6
container_name: myRedis
restart: always
ports:
- 6380:6379
volumes:
- /var/redis/data:/data:rw
- /usr/local/redis/redis.conf:/etc/redis/redis.conf:rw
command:
redis-server /etc/redis/redis.conf