一、配置镜像源
sudo vim /etc/docker/daemon.json
添加下面内容:
{
"registry-mirrors": [
"https://docker.1ms.run",
"https://docker.xuanyuan.me"
]
}
二、加载配置并重启容器
systemctl daemon-reload
systemctl restart docker
三、查看镜像版本
四、拉取redis镜像
docker pull redis:6-alpine
五、配置docker-compose.yml
services:
redis:
image: redis:6-alpine
restart: always
environment:
REDISCLI_AUTH: 密码
volumes:
# Mount the redis data directory to the container.
- ./volumes/redis/data:/home/dify/data/redis
# Set the redis password when startup redis server.
command: redis-server --requirepass 密码
ports:
- "6379:6379" # 将容器内的 6379 端口映射到主机的 6379 端口
healthcheck:
test: [ 'CMD', 'redis-cli', 'ping' ]
六、启动redis容器
docker-compose up -d redis
七、检查Redis容器是否启动成功
检查容器是否启动成功
docker ps
八、检查Redis是否可用
1.查看端口:
sudo netstat -tuln | grep 6379
2.进入容器查看命令行:
docker exec -it e02f6ba0f819 /bin/sh
[root@localhost dify]# docker exec -it e02f6ba0f819 /bin/sh
/data # redis-cli
127.0.0.1:6379> AUTH difyai123456
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> SET testkey "Hello, Redis!"
OK
127.0.0.1:6379> GET testkey
"Hello, Redis!"