0

How can I connect from docker-compose to the host. In the docker-compose there is an nginx and php running and I would like for the php container to connect to a mysql database that is running on the host. the nginx and php containers are connected via a docker-compose network.

Here is the docker-compose file:

version: '3'

networks:
    test:

services:
    nginx:
        some stuff
        networks:
            - test

    php:
        some stuff
        networks:
            - test
            - HOST?????

I think in the php application I would then connect to "localhost" and docker connects this the host.

Is this possible? I have read, that it is possible for individual containers to be connected to the host, but don't know if it is possible when docker-compose is used.

pls_help
  • 71
  • 1
  • 2
  • 9

0 Answers0