docker / for-mac

Bug reports for Docker Desktop for Mac
https://www.docker.com/products/docker#/mac
2.43k stars 118 forks source link

Resolving hosts works incorrectly on Macos M2 processor. Error : 'php_network_getaddresses: getaddrinfo for <host> failed: nodename nor servname provided, or not known' is shown #7449

Open MargaretKedvenc opened 1 day ago

MargaretKedvenc commented 1 day ago

Description

Error is shown: An exception occurred in the driver: 'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for api-db failed: nodename nor servname provided, or not known ' Context: while execution migrate command it calls internal host and port, but should call to external (executing in the IDE), Network - container name is existed and correct in the network. container is alive, connection to db is good inside the container. Container log is correct and finished with ready to connection. Execution this command in the container works correctly, but not outside. '2024-09-12 15:13:55 2024-09-12T13:13:55.682087Z 0 [Note] mysqld: ready for connections. 2024-09-12 15:13:55 Version: '5.7.34' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)' Config docker-compose.yml: api-db: image: mysql:5.7.34 platform: linux/amd64 restart: always environment: MYSQL_ROOT_PASSWORD: ** MYSQL_DATABASE: ** MYSQL_USER: MYSQL_PASSWORD: *** command:

Reproduce

  1. Setup env, docker build, docker up
  2. make sure that all containers are alive
  3. run some command in the IDE terminal(outside the container) where call must use db service(f.e. php bin/console doctrine:migrations:migrate)
  4. Pay attention on the error ' PDO::__construct(): php_network_getaddresses: getaddrinfo for api-db failed: nodename nor servname provided, or not known '

Expected behavior

Outer containers command should automatically be resolved on the outer hosts and port (localhost::3310). There's no error 'PDO::__construct(): php_network_getaddresses: getaddrinfo for api-db failed: nodename nor servname provided, or not known ' while running the command outside the containers.

docker version

Client: Version: 27.2.0 API version: 1.47 Go version: go1.21.13 Git commit: 3ab4256 Built: Tue Aug 27 14:14:45 2024 OS/Arch: darwin/arm64 Context: desktop-linux

Server: Docker Desktop 4.34.2 (167172) Engine: Version: 27.2.0 API version: 1.47 (minimum version 1.24) Go version: go1.21.13 Git commit: 3ab5c7d Built: Tue Aug 27 14:15:41 2024 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.7.20 GitCommit: 8fc6bcff51318944179630522a095cc9dbf9f353 runc: Version: 1.1.13 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0

docker info

Client: Version: 27.2.0 Context: desktop-linux Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.16.2-desktop.1 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.29.2-desktop.2 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-compose debug: Get a shell into any image or container (Docker Inc.) Version: 0.0.34 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-debug desktop: Docker Desktop commands (Alpha) (Docker Inc.) Version: v0.0.15 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-desktop dev: Docker Dev Environments (Docker Inc.) Version: v0.1.2 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-dev extension: Manages Docker extensions (Docker Inc.) Version: v0.2.25 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-extension feedback: Provide feedback, right in your terminal! (Docker Inc.) Version: v1.0.5 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-feedback init: Creates Docker-related starter files for your project (Docker Inc.) Version: v1.3.0 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-init sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.) Version: 0.6.0 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-sbom scout: Docker Scout (Docker Inc.) Version: v1.13.0 Path: /Users/margaret_kedvenc/.docker/cli-plugins/docker-scout

Server: Containers: 34 Running: 34 Paused: 0 Stopped: 0 Images: 30 Server Version: 27.2.0 Storage Driver: stargz driver-type: io.containerd.snapshotter.v1 Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: 8fc6bcff51318944179630522a095cc9dbf9f353 runc version: v1.1.13-0-g58aa920 init version: de40ad0 Security Options: seccomp Profile: unconfined cgroupns Kernel Version: 6.10.4-linuxkit Operating System: Docker Desktop OSType: linux Architecture: aarch64 CPUs: 6 Total Memory: 9.706GiB Name: docker-desktop ID: 8691f7f3-5dc4-46d1-bace-bc95e38c2023 Docker Root Dir: /var/lib/docker Debug Mode: false HTTP Proxy: http.docker.internal:3128 HTTPS Proxy: http.docker.internal:3128 No Proxy: hubproxy.docker.internal Labels: com.docker.desktop.address=unix:///Users/margaret_kedvenc/Library/Containers/com.docker.docker/Data/docker-cli.sock Experimental: false Insecure Registries: hubproxy.docker.internal:5555 127.0.0.0/8 Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile

Diagnostics ID

0647105F-958C-404C-B9E6-239A470E4EAB/20241008074033

Additional Info

Dev log: [2024-10-08T08:11:21.364535+00:00] doctrine.INFO: Connecting with parameters array{"driver":"pdo_mysql","host":"api-db","port":3306,"user":"apiuser","password":"","driverOptions":[],"wrapperClass":"Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection","serverVersion":"5.7","defaultTableOptions":{"collation":"utf8mb4_unicode_ci"},"dbname":"api","charset":"utf8mb4"} {"params":{"driver":"pdo_mysql","host":"api-db","port":3306,"user":"apiuser","password":"","driverOptions":[],"wrapperClass":"Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection","serverVersion":"5.7","defaultTableOptions":{"collation":"utf8mb4_unicode_ci"},"dbname":"api","charset":"utf8mb4"}} [] [2024-10-08T08:11:21.391655+00:00] app.DEBUG: Saving the queue message via the producer "event_exception_thrown"... Payload: {"type":"Event.ExceptionThrown","source":"api","correlationId":"not-implemented","data":{"exceptionClass":"Doctrine\DBAL\Exception\ConnectionException","file":"\/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/doctrine\/dbal\/src\/Driver\/API\/MySQL\/ExceptionConverter.php","line":101,"message":"An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for api-db failed: nodename nor servname provided, or not known","trace":"#0 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/doctrine\/dbal\/src\/Connection.php(1935): Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert(Object(Doctrine\DBAL\Driver\PDO\Exception), NULL)\n#1 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/doctrine\/dbal\/src\/Connection.php(1884): Doctrine\DBAL\Connection->handleDriverException(Object(Doctrine\DBAL\Driver\PDO\Exception), NULL)\n#2 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/doctrine\/dbal\/src\/Connection.php(377): Doctrine\DBAL\Connection->convertException(Object(Doctrine\DBAL\Driver\PDO\Exception))\n#3 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/facile-it\/doctrine-mysql-come-back\/src\/ConnectionTrait.php(126): Doctrine\DBAL\Connection->connect(NULL)\n#4 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/doctrine\/dbal\/src\/Connection.php(1652): Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection->connect()\n#5 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/doctrine\/dbal\/src\/Connection.php(1079): Doctrine\DBAL\Connection->getWrappedConnection()\n#6 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/facile-it\/doctrine-mysql-come-back\/src\/ConnectionTrait.php(155): Doctrine\DBAL\Connection->executeQuery('SELECT DATABASE...', Array, Array, NULL)\n#7 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/facile-it\/doctrine-mysql-come-back\/src\/ConnectionTrait.php(84): Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection->Facile\DoctrineMySQLComeBack\Doctrine\DBAL\{closure}()\n#8 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/facile-it\/doctrine-mysql-come-back\/src\/ConnectionTrait.php(154): Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection->doWithRetry(Object(Closure), 'SELECT DATABASE...')\n#9 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/doctrine\/dbal\/src\/Connection.php(619): Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection->executeQuery('SELECT DATABASE...', Array, Array)\n#10 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/doctrine\/dbal\/src\/Connection.php(260): Doctrine\DBAL\Connection->fetchOne('SELECT DATABASE...')\n#11 \/Users\/margaret_kedvenc\/Projects\/1684\/deployment\/src\/api\/vendor\/doctrine\/migrations\/lib\/Doctrine\/Migrations\/Tools\/Console\/Command\/MigrateCommand.php(133): Doctrine\DBAL\Connection->getDatabase()\n...","serviceName":"api","hostName":"Mac"}} [] [] [2024-10-08T08:11:21.436461+00:00] doctrine.INFO: Connecting with parameters array{"driver":"pdo_mysql","host":"api-db","port":3306,"user":"apiuser","password":"","driverOptions":[],"wrapperClass":"Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection","serverVersion":"5.7","defaultTableOptions":{"collation":"utf8mb4_unicode_ci"},"dbname":"api","charset":"utf8mb4"} {"params":{"driver":"pdo_mysql","host":"api-db","port":3306,"user":"apiuser","password":"","driverOptions":[],"wrapperClass":"Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection","serverVersion":"5.7","defaultTableOptions":{"collation":"utf8mb4_unicode_ci"},"dbname":"api","charset":"utf8mb4"}} []

unfixa1 commented 8 hours ago

On the M1/M2 architecture, Docker Desktop may have some specific network configuration issues. You can use servbay to check environment compatibility issues, which is very convenient for database connection and PHP environment setup.