docker pull redis:4.0git
拉取Redis4.0鏡像github
docker imagesredis
查看本地的鏡像docker
mkdir -p /root/redis4.0/datavim
在宿主機建立數據文件目錄app
wget https://raw.githubusercontent.com/antirez/redis/4.0/redis.conf -O /root/redis4.0/redis.confui
獲取redis4.0的默認配置文件模版spa
chmod -R 777 redis4.0rest
賦予redisredis4.0目錄最高讀寫權限blog
docker run --restart=always --name redis4.0 -p 6379:6379 -v /root/redis4.0/redis.conf:/etc/redis/redis.conf -v /root/redis4.0/data:/data -d redis:4.0 --appendonly yes --requirepass "Abcdef@123456"
運行容器,映射端口,掛載配置文件與數據文件,並開啓數據持久化
docker ps
查看正在運行的容器
vim /root/redis4.0/redis.conf
修改宿主機的配置文件
第69行註釋掉並改成
# bind 127.0.0.1
第88行改成
protected-mode no
第136行改成
daemonize yes
第500行取消註釋並改成
requirepass Abcdef@123456
docker restart redis4.0
重啓容器