Phpunit没有与docker中的mysql连接

问题描述 投票:0回答:1

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
docker docker-compose phpunit
1个回答
0
投票

environment服务的db配置和args服务的php设置应该以-字符开始。

© www.soinside.com 2019 - 2024. All rights reserved.