First see this answer for the options that you have to fix this problem. But if you use docker-compose
you can add network_mode: host
to your service and then use 127.0.0.1
to connect to the local host. This is just one of the options described in the answer above. Below you can find how I modified docker-compose.yml
from https://github.com/geerlingguy/php-apache-container.git
:
---
version: "3"
services:
php-apache:
+ network_mode: host
image: geerlingguy/php-apache:latest
container_name: php-apache
...
+
indicates the line I added.
[Additional info] This has also worked in version 2.2
. and "host" or just 'host' are both worked in docker-compose
.
---
version: "2.2"
services:
php-apache:
+ network_mode: "host"
or
+ network_mode: host
...