I am trying to connect django to a container of a redix container
Here is my docker file
FROM ubuntu:14.04 RUN apt-get update && apt-get install -y redis-server EXPOSE 6379 ENTRYPOINT ["/usr/bin/redis-server"]
Here is the result of docker ps -a
4f7eaeb2761b /redis "/usr/bin/redis-serve" 16 hours ago Up 16 hours 6379/tcp redis
Here's a quick health check that redis works inside a docker container
docker exec -ti redis bash root@4f7eaeb2761b :/# redis-cli ping PONG root@4f7eaeb2761b :/
Here is my Django settings.py
CACHES = { 'default': { 'BACKEND': 'redis_cache.RedisCache', 'LOCATION': 'localhost:6379', }, }
Here is my look
from django.shortcuts import render from django.template import loader from django.http import HttpResponse from django.views.decorators.cache import cache_page @cache_page(60 * 15) def index(request): template = loader.get_template('./index.html') return HttpResponse(template.render())
Below is an alternative access to redis
import redis def index(request): r = redis.StrictRedis(host='localhost', port=6379, db=0) print r
I checked that everything works without the @cache_page
decorator
When I used the decorator, I get
Error 61 connecting to localhost:6379. Connection refused.
I'm not sure how I can open the docker container by setting the Expose
port, any help would be appreciated
thanks