1.拉取最新的redis镜像
docker pull redis;
2.创建存放redis数据的目录
mkdir /redis/data
3.查询redis镜像id
docker images;
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 3c41ce05add9 13 days ago 95MB
4.查看当前正在运行的容器
docker ps;
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5.运行redis容器
docker run -dit -v /redis/data:/data -p 6379:6379 redis -a "root";(加-a "root"会出错?)
6.查看当前正在运行的容器
docker ps;
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
10b9b9b5cb64 redis "docker-entrypoint.s…" 4 seconds ago Up 2 seconds 0.0.0.0:6379->6379/tcp