下载redis
$ docker pull redis
创建配置文件
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
启动redis
$ docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf
开启持久化
vim /mydata/redis/conf/redis.conf
添加一下配置
appendonly yes
进入redis cli
$ docker exec -it redis redis-cli
开机自启
sudo docker update redis --restart=always