Xdebug doen't connect: Virtualhosts with Apache2 and PHP-FPM

The problem is that localhost and 127.0.0.1 inside the container isn’t your host machine, it’s the VM layer. 172.20.0.1 isn’t your host necessarily either. As far as I know, Docker for Mac doesn’t provide network information about your host. There has been rounds of these kinds of questions around the forum as well as on Docker’s Github issue tracker.

See How to reach MacOSX from Container? for options