我有2个laravel项目,其中包含2个docker-compose文件docker-compose-1.yml和docker-compose-2.yml。我希望这两个项目在docker-compose-1.yml中连接相同的redis容器。
env文件是相同的:
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
docker-compose-1.yml:
redis:
build:
context: ./docker/redis
volumes:
- ./docker/docker-runtime/redis/data:/data
expose:
- "6379"
最后project1已成功连接到Redis。但是项目2失败了。错误消息:
Predis \ Connection \ ConnectionException
php_network_getaddresses: getaddrinfo failed: Name or service not known [tcp://redis:6379]
project2应该如何连接到redis?