when i try to initialize a new client $tkRedis = new Client();
i get an error message
Connection refused [tcp://127.0.0.1:6379]
The container of Redis is running. But I can't establish a connection with predis.
Part of my docker-compose.yml:
redis:
image: library/redis:latest
command: redis-server
ports:
- 6379:6379
environment:
- REDIS_REPLICATION_MODE=master
container_name: ver-v2-cache-redis
networks:
- ver-v2-net
127.0.0.1 is the localhost. Your php container is not hosting the Redis server. If you are attached to the same docker network (ver-v2-net in this case), you can reach the server by using the container name and the designated port: redis:6379