搜索镜像
[root@localhost ~]# docker search redis
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
redis Redis is an open source key-value store that… 10202 [OK]
sameersbn/redis 83 [OK]
grokzen/redis-cluster Redis cluster 3.0, 3.2, 4.0, 5.0, 6.0, 6.2 80
rediscommander/redis-commander Alpine image for redis-commander - Redis man… 70 [OK]
redislabs/redisearch Redis With the RedisSearch module pre-loaded… 41
redislabs/redisinsight RedisInsight - The GUI for Redis 35
kubeguide/redis-master redis-master with "Hello World!" 33
oliver006/redis_exporter Prometheus Exporter for Redis Metrics. Supp… 31
redislabs/redis Clustered in-memory database engine compatib… 31
redislabs/rejson RedisJSON - Enhanced JSON data type processi… 31
arm32v7/redis Redis is an open source key-value store that… 25
arm64v8/redis Redis is an open source key-value store that… 19
redislabs/redisgraph A graph database module for Redis 17 [OK]
redislabs/rebloom A probablistic datatypes module for Redis 16 [OK]
redislabs/redismod An automated build of redismod - latest Redi… 15 [OK]
webhippie/redis Docker image for redis 11 [OK]
s7anley/redis-sentinel-docker Redis Sentinel 10 [OK]
insready/redis-stat Docker image for the real-time Redis monitor… 10 [OK]
redislabs/redistimeseries A time series database module for Redis 10
goodsmileduck/redis-cli redis-cli on alpine 9 [OK]
centos/redis-32-centos7 Redis in-memory data structure store, used a… 6
clearlinux/redis Redis key-value data structure server with t… 3
tiredofit/redis Redis Server w/ Zabbix monitoring and S6 Ove… 1 [OK]
wodby/redis Redis container image with orchestration 1 [OK]
xetamus/redis-resource forked redis-resource 0 [OK]
拉取镜像
[root@localhost ~]# docker pull redis
Using default tag: latest
latest: Pulling from library/redis
eff15d958d66: Pull complete
1aca8391092b: Pull complete
06e460b3ba1b: Pull complete
def49df025c0: Pull complete
646c72a19e83: Pull complete
db2c789841df: Pull complete
Digest: sha256:619af14d3a95c30759a1978da1b2ce375504f1af70ff9eea2a8e35febc45d747
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest
设置docker-compose.yml配置
[root@localhost bin]# vi docker-compose.yml
version: '3'
services:
redis:
image: redis:latest
restart: always
container_name: redis
command:
- /bin/bash
- -c
- redis-server /usr/local/bin/redis.conf/redis.conf --requirepass "xxxxxxxx"
privileged: true
ports:
- "0.0.0.0:6379:6379"
volumes:
- ./redis/data:/data
- ./redis/redis.conf:/usr/local/bin/redis.conf/redis.conf
创建Redis容器
[root@localhost bin]# docker-compose up -d
Creating redis ... done
[root@localhost bin]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e558e25c45bb redis:latest "docker-entrypoint.s…" 13 minutes ago Up 13 minutes 0.0.0.0:6379->6379/tcp redis
本机客户端登录
root@e558e25c45bb:/usr/local/bin#
root@e558e25c45bb:/usr/local/bin# ./redis-cli -h 127.0.0.1 -p 6379 -a "xxxxxx"
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>