1.使用docker search redis
查看可用版本
xiong@xiong-pc:~$ docker search redis
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
redis Redis is an open source key-value store that… 11236 [OK]
bitnami/redis Bitnami Redis Docker Image 228 [OK]
bitnami/redis-sentinel Bitnami Docker Image for Redis Sentinel 39 [OK]
bitnami/redis-cluster 34
rapidfort/redis RapidFort optimized, hardened image for Redi… 15
rapidfort/redis-cluster RapidFort optimized, hardened image for Redi… 15
circleci/redis CircleCI images for Redis 14 [OK]
redis/redis-stack redis-stack installs a Redis server with add… 11
ubuntu/redis Redis, an open source key-value store. Long-… 10
bitnami/redis-exporter 9
redis/redis-stack-server redis-stack-server installs a Redis server w… 8
clearlinux/redis Redis key-value data structure server with t… 4
ibmcom/redis-ha 1
bitnami/redis-sentinel-exporter 1
ibmcom/ibm-cloud-databases-redis-operator Container image for the IBM Operator for Red… 1
vmware/redis-photon 0
greenbone/redis-server A redis service container image for the Gree… 0
cimg/redis 0
ibmcom/redis-ppc64le 0
rancher/redislabs-ssl 0
drud/redis redis 0 [OK]
corpusops/redis https://github.com/corpusops/docker-images/ 0
blackflysolutions/redis Redis container for Drupal and CiviCRM 0
ibmcom/redisearch-ppc64le 0
rapidfort/redis6-ib RapidFort optimized, hardened image for Redi… 0
xiong@xiong-pc:~$
2.使用docker pull redis
拉取官方最新版镜像
xiong@xiong-pc:~$ docker pull redis
Using default tag: latest
latest: Pulling from library/redis
a2abf6c4d29d: Pull complete
c7a4e4382001: Pull complete
4044b9ba67c9: Pull complete
c8388a79482f: Pull complete
413c8bb60be2: Pull complete
1abfd3011519: Pull complete
Digest: sha256:db485f2e245b5b3329fdc7eff4eb00f913e09d8feb9ca720788059fdc2ed8339
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
xiong@xiong-pc:~$
3.查看本地镜像docker images
xiong@xiong-pc:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 7614ae9453d1 7 months ago 113MB
mysql latest 3218b38490ce 7 months ago 516MB
xiong@xiong-pc:~$
4.运行redis
容器 docker run -itd --name redis-test -p 6379:6379 redis
xiong@xiong-pc:~$ docker run -itd --name redis-test -p 6379:6379 redis
5ce0ba36323d7905a760186a516531c27ff633eae47f0509d047b177ca119c34
xiong@xiong-pc:~$
参数说明:
- -name:后面是docker容器名
- -p 6379:6379:映射容器服务的 6379 端口到宿主机的 6379 端口。外部可以直接通过宿主机ip:6379 访问到 Redis 的服务。
5.使用docker ps
查看是否安装成功
xiong@xiong-pc:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5ce0ba36323d redis "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis-test
0401092b4399 mysql "docker-entrypoint.s…" 2 months ago Up 3 days 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
xiong@xiong-pc:~$