简体   繁体   中英

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 ('127.0.0.1', 6379)

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

Dockerfile: gist , OS: macOS 10.12

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM