Using Docker I get the error: “SQLSTATE[HY000] [2002] No such file or directory”

后端 未结 3 1830
一个人的身影
一个人的身影 2020-12-07 20:59

I\'m using Docker to create a container to test my web app built on PHP and MySQL on my Mac. My PHP app is built using Fat-Free Framework for MVC and routing. I have two D

3条回答
  •  旧时难觅i
    2020-12-07 21:39

    You can use this command

    docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)

    Containers will connect with each other by their ip For example: My ip list is:

    /nginx - 172.23.0.4

    /php - 172.23.0.3

    /mysql - 172.23.0.2

    Put this ip-address into your config file instead of 127.0.0.1. Hope that it will help you!

提交回复
热议问题