我需要在我的Laravel应用程序中配置Redis与Socketio。然而,无论我尝试了什么,我都得到了相同的错误信息:Connection refused [tcp://127.0.0.1:6379]。 我可以通过docker exec -it id sh命令进入容器,当我ping服务器时,我会收到PONG消息。客户端已经在我的database.php文件中设置为'predis',并且该软件包也已安装。以下是.env文件的内容。
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
docker-compose.yml
version: "2"
services:
api:
build: .
ports:
- 9000:9000
volumes:
- .:/app
- /app/vendor
depends_on:
- postgres
- redis
environment:
DATABASE_URL: postgres://xx@postgres/xx
postgres:
image: postgres:latest
environment:
POSTGRES_USER: xx
POSTGRES_DB: xx
POSTGRES_PASSWORD: xx
volumes:
- .Data:/var/lib/postgresql/data
ports:
- 3306:5432
redis:
build: ./Redis/
ports:
- 6003:6379
volumes:
- ../RedisData/data:/data
command: redis-server --appendonly yes
Dockerfile (redis)
FROM redis:alpine
COPY redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
.env
文件?错误明显地显示你的主机设置为127.0.0.1
。 - Kevin Kopf