第一步:docker search redis

第二步:docker pull redis

第三步:查看docker images,可以看到redis

第四步:在 /home/sharps/tools目录下创建 redis目录
sharps@sharps-computer:~/tools$ cd /home/sharps/tools
sharps@sharps-computer:~/tools$ mkdir redis

第五步:进入redis目录中,下载配置文件
sharps@sharps-computer:~/tools$ cd redis
sharps@sharps-computer:~/tools/redis$ wget http://download.redis.io/redis-stable/redis.conf
可以编辑redis.conf来配置

第六步:启动redis容器
docker run
–name redis
-d -p 6379:6379
-v /home/sharps/tools/redis/redis.conf:/etc/redis.conf
redis redis-server /etc/redis.conf

第七步:使用docker ps 查看redis已经运行了

第八步:使用 docker exec -it redis /bin/bash进入redis

第九步:测试连接
使用 redis-cli 可以测试连接











