下载redis镜像
首先查看一下redis
是否正确:
docker search redis
显示:
NAME DESCRIPTION STARSOFFICIAL AUTOMATEDredis Redis is an open source key-value store that… 9636[OK]bitnami/redisBitnami Redis Docker Image 184 [OK]grokzen/redis-cluster Redis cluster 3.0, 3.2, 4.0, 5.0, 6.0, 6.278rediscommander/redis-commander Alpine image for redis-commander - Redis man… 61 [OK]redislabs/redisearch Redis With the RedisSearch module pre-loaded… 34redislabs/redisinsight RedisInsight - The GUI for Redis32redislabs/redis Clustered in-memory database engine compatib… 31oliver006/redis_exporterPrometheus Exporter for Redis Metrics. Supp… 28.....
然后把redis
拉到本地就好:
docker pull redis
然后运行:
docker images
可以看到多了一个:redis latest 08502081bff6 8 days ago 105MB
运行docker redis
这个docker的id是08502081bff6
,所以首先运行这个镜像到容器中:
docker run -dit 08502081bff6
然后查看容器:
docker ps
可以看到:063c45279282 08502081bff6 "docker-entrypoint.s…" 2 seconds ago Up 2 seconds 6379/tcp fervent_wu
,其中容器ID为063c45279282
,
所以进入这个容器:
docker exec -it 063c45279282 /bin/bash
然后就是docker
里redis
的命令行了
启动与运行redis命令
启动redis
:
redis-server
如果是docker中,会发现服务 已经启动了:
40:C 02 Jul 12:29:03.373 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo40:C 02 Jul 12:29:03.374 # Redis version=6.2.4, bits=64, commit=00000000, modified=0, pid=40, just started40:C 02 Jul 12:29:03.374 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf40:M 02 Jul 12:29:03.376 * monotonic clock: POSIX clock_gettime40:M 02 Jul 12:29:03.376 # Warning: Could not create server TCP listening socket *:6379: bind: Address already in use40:M 02 Jul 12:29:03.377 # Failed listening on port 6379 (TCP), aborting.
这样就已经启动redis
了,最后运行:
redis-cli
就是redis数据库的命令行了!
更多请参考docker hub:/_/redis
如果觉得《redis docker安装 进入命令行后启动服务》对你有帮助,请点赞、收藏,并留下你的观点哦!