【发布时间】:2021-06-01 13:12:51
【问题描述】:
Python 和 Redis 在我的本地可以很好地协同工作。我尝试将项目 docker 化。
当我 docker-compose up 时,redis 容器工作正常。
> Server initialized
> Ready to accept connections
但是当我在 POSTMAN 中调用请求时,出现以下错误:
Error 111 connecting to 0.0.0.0:6379. Connection refused.
我的设置:
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://0.0.0.0:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
}
我的 docker-compose.yml:
redis:
image: bitnami/redis:latest
volumes:
- ./redis.conf:/usr/local/etc/redis/redis.conf
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- "6379:6379"
...在 Dockerfile 中:
ENV REDIS_URL=redis://0.0.0.0:6379/1
我错过了什么?
【问题讨论】:
标签: python django docker redis