docker search redis
查询可用的镜像
docker pull redis
拉取redis镜像,默认为最新版本
查找其他版本镜像:
进入 https://hub.docker.com/r/library/
搜索镜像名称,进入镜像查看tag标签。
详细:https://www.php.cn/docker/446328.html
配置yaml文件
version: '2'
services:
redis:
image: redis
container_name: redis
restart: always
ports:
- "6379:6379"
volumes:
- "./static/data/:/data/"
command: redis-server --appendonly yes [设置持久化]
运行容器
docker-compose -f redis-compose.yaml up -d
-f:指定yaml文件
-d:后台运行