Docker安装Redis

在Docker Hub上查询可用版本


Redis可用版本

下载并安装6.2.6版本

(base) ArchitectRoad: joey$docker pull redis:6.2.6
(base) ArchitectRoad: joey$docker images
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
redis        6.2.6     0e403e3816e8   3 days ago   113MB

运行redis

#启动容器
docker run -itd --name redis -p 6379:6379 redis:6.2.6
(base) ArchitectRoad: joey$docker ps
CONTAINER ID   IMAGE         COMMAND                  CREATED          STATUS          PORTS                               NAMES
88c73b87e1e0   redis:6.2.6   "docker-entrypoint.s…"   10 seconds ago   Up 9 seconds    0.0.0.0:6379->6379/tcp              redis
b43a801ca528   mysql:8.0     "docker-entrypoint.s…"   17 minutes ago   Up 17 minutes   0.0.0.0:3306->3306/tcp, 33060/tcp   mysql

测试redis

(base) ArchitectRoad: joey$docker exec -it 88c73b87e1e0 /bin/sh
root@88c73b87e1e0:/data# redis-cli
127.0.0.1:6379> set key 123
OK

你可能感兴趣的:(Docker安装Redis)