Docker 官方 Redis 镜像的使用说明文档
使用 Docker 官方的 Redis 镜像
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 # docker search redis# docker pull redis:5.0# docker run -p 6379:6379 --name redis5.0 \ -v /container/redis5.0/data:/data \ -d redis:5.0 redis-server --appendonly yes# docker run -p 6379:6379 --name redis5.0 \ -v /container/redis5.0/conf/redis.conf:/usr/local /etc/redis/redis.conf \ -v /container/redis5.0/data:/data \ -d redis:5.0 redis-server /usr/local /etc/redis/redis.conf/container └── redis5.0 ├── conf │ └── redis.conf │ └── redis.conf └── data # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES dbe17690112d redis:5.0 "docker-entrypoint.s…" 3 minutes ago Up 3 minutes 0.0.0.0:6379->6379/tcp redis5.0 # docker exec -it redis5.0 /bin/bash# redis -cli -p 6379
验证 Redis 服务器是否可用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 # docker exec -it redis5.0 redis-cli# docker exec -it redis5.0 redis-cli -p 6379127.0.0.1:6379> set key1 helloworld 127.0.0.1:6379> get key1 127.0.0.1:6379> exit