Keith
October 9, 2017, 9:39am
1
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.
clay
October 9, 2017, 7:21pm
2
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:
Open Terminal
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.
Keith
October 10, 2017, 12:57am
3
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
Keith
November 2, 2017, 10:43pm
4
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.