sudo docker search redis
sudo docker pull redis
sudo docker run --name redis6379 -p 6379:6379 -v /opt/docker/redis:/data -d redis:3.2 redis-server --appendonly yes
5dc4f5ba13f9fb5e40336cffe88107f0e7331dbb506fc8dd53f48f91c88d7411
命令说明:
-p 6379:6379 :将容器的6379端口映射到主机的6379端口
-v $PWD/data:/data :将主机中当前目录下的data挂载到容器的/data
redis-server --appendonly yes :在容器执行redis-server启动命令,并打开redis持久化配置