Symfony连接数据库(和php容器),但是当我运行phpunit时返回错误SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
。我的项目在哪里出错?
在我的项目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
答案 0 :(得分:0)
environment
服务的db
配置和args
服务的php
设置应以-
字符开头。