Folks: I am moving my Flask app with redis for session storage into docker containers. My app runs happily when redis is run locally. However, when running a docker-compose with a redis image, I see the following error. I get an identical error whether my redis container is running or stopped:
2017-04-02 03:36:09,861] ERROR in app: Exception on / [GET]
web_1 | Traceback (most recent call last):
web_1 | File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
web_1 | response = self.full_dispatch_request()
web_1 | File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1643, in full_dispatch_request
web_1 | response = self.process_response(response)
web_1 | File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1864, in process_response
web_1 | self.save_session(ctx.session, response)
web_1 | File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 926, in save_session
web_1 | return self.session_interface.save_session(self, session, response)
web_1 | File "/usr/local/lib/python2.7/site-packages/flask_session/sessions.py", line 165, in save_session
web_1 | self.redis.setex(name=self.key_prefix + session.sid, value=val,
web_1 | AttributeError: 'str' object has no attribute 'setex'
I have added the following configuration properties to my app for session config:
SESSION_TYPE = "redis"
SESSION_REDIS = "redis:6379"
I don't think this is a docker-compose
issue as my app is successfully able to connect to the MySQL instance, still, here is my docker-compose.yml
file just in case it points to something:
version: "3"
services:
mysql:
build:
context: db/
web:
build:
context: web/
ports:
- "10080:80"
depends_on:
- "mysql"
- "redis"
redis:
image: "redis:alpine"