0x1337 0x1337 - 3 days ago 7
Python Question

Unnable to connect to Redis from inside Docker container

When I start Docker container I get

OSError: Multiple exceptions: [Errno 111] Connect call failed ('::1', 6379), [Errno 111] Connect call failed ('', 6379)

from Python, but this code works fine on the host machine. How to fix this?

Dockerfile: gist, OS: macOS 10.12

Answer Source

You can only have a single CMD statement. To start both redis-server and python inside a single container you'll need to define a script or run a tool like supervisord to manage your processes. https://docs.docker.com/engine/admin/multi-service_container/ explains some options and also gives examples. In your case I would give the approach with a shell script a try. The Phusion base image https://github.com/phusion/baseimage-docker is a more advanced alternative, starting each process via init service, but might be overkill for your use case.