search

Home  >  Q&A  >  body text

The rewritten title is: Configuring PHPUnit database using PhpStorm Docker


Illuminate database QueryException: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: name cannot be resolved (SQL: select * from Table name)

The tests run in the container but are broken in the IDE. Do you know what the problem is in PhpStorm?

P粉111641966P粉111641966396 days ago756

reply all(1)I'll reply

  • P粉154798196

    P粉1547981962023-11-02 18:26:28

    I encountered this problem. Assuming you've set up a Docker container and a PHP interpreter, this is how I connected to the MySQL container:

    1. Run docker network ls from the CLI and see the "lighthouse_default" network
    2. Go to PHP > Test Framework and edit on my Docker container (click on the folder)
    3. Set network mode to "lighthouse_default"
    4. Add lighthouse_mysql_1 image to Links section

    Obviously the network name may be different in your case. The real point is that I have to make sure I'm using the correct network and make sure the database image is in the container link.

    reply
    0
  • Cancelreply