Symfony连接数据库(和PHP容器),但当我运行phpunit返回错误SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
。我的项目在哪里出错?
在我的projekt docker-compose.yml文件中看起来像:
services:
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- 8989:3306
php:
build:
context: docker/php7-fpm
args:
TIMEZONE: ${TIMEZONE}
volumes:
- ${SYMFONY_APP_PATH}:/var/www/symfony
- ./logs/symfony:/var/www/symfony/app/logs
depends_on:
- db
links:
- db:db
environment
服务的db
配置和args
服务的php
设置应该以-
字符开始。