IP of HOST available within site container?

Does the site docker container know the IP Address of its host?
Is it, or could it be available though an environment variable?

I would like access to a database running on the host, in addition to the one running within the container. Is the host even reachable?

K.

Hi Keith,

I just tested it and it’s reachable on macOS. I can’t make any guarantees about Windows.

Here’s how you can get the host IP on macOS:

  1. Open Terminal
  2. Run "/Applications/Local by Flywheel.app/Contents/Resources/extraResources/virtual-machine/vendor/docker/osx/docker-machine" ssh local-by-flywheel "route | grep default" | awk '{ print $2 }'

On my computer get 10.0.2.2. This IP should work in every site container.

Thank you. If I understand you correctly, 10.0.2.2 is mapped to the host, whatever the hosts ethernet ip is.

I also tried connecting to a database using the host’s ethernet ip and it appeared to work, but your solution is what I was looking for, thanks

K.

1 Like

I am trying to organise phpunit to work inside the docker container, both on the command line and via the browser.

What is the best way to find the port of my site’s MySql instance.

Could some of this configuration information be made available in the environment variables when opening an SSH shell, or for the www-data user available via getenv() in php code.

K.