I have containerized a simple PHP app. It needs to connect to the host's database (localhost) and do some operations. However, while running the app, I have the following error:
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory ...
My docker-compose file looks like this:
version: "3.9"
services:
app:
build: .
stdin_open: true
tty: true
network_mode: "host"
restart: on-failure
Looks like dockerized app can't connect with localhost database. I added network_mode: "host"
, but it didn't help.
I use Docker Desktop and Mac OS.