数据库 - Redis
Docker Hub:https://hub.docker.com/_/redis (opens new window)
# 常用命令
docker run \
--name <容器名称> \
-v <配置:挂载卷|宿主机路径>:/usr/local/etc/redis \
-v <持久化:挂载卷|宿主机路径>:/data \
-p 6379:6379 \
-d \
redis redis-server /usr/local/etc/redis/redis.conf
docker run \
--name my-redis \
-v /data/redis/config:/usr/local/etc/redis \
-v /data/redis/data:/data \
-p 6379:6379 \
-d \
redis redis-server /usr/local/etc/redis/redis.conf
// Make sure to add code blocks to your code group
配置: <配置:挂载卷|宿主机路径>/redis.conf
,需提前创建好!
redis.conf 参考配置:官方配置文档 (opens new window)
appendonly yes
requirepass <访问密码>
# Compose
services:
redis:
image: redis
container_name: my-redis
volumes:
- /data/redis/config:/usr/local/etc/redis
- /data/redis/data:/data
ports:
- "6379:6379"
command: redis-server /usr/local/etc/redis/redis.conf
上次更新: 2024/08/25, 02:09:30