Docker启动redis(预先准备配置文件)
一、准备配置文件
在/Users/gavin/Documents/docker/redis/conf目录下面新建redis.conf文件
(如果是linux服务器建议设置在/root/redis/conf/redis.conf)
bind 0.0.0.0 protected-mode yes port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 0 loglevel notice logfile "" databases 4 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir ./ requirepass abc123456
二、创建容器,做好端口和文件夹映射
docker run --restart=always -it -d --name redis -p 6379:6379 \ -v /Users/gavin/Documents/docker/redis/conf:/usr/local/etc/redis \ -e TZ=Asia/Shanghai \ redis:6.0.10 \ redis-server /usr/local/etc/redis/redis.conf