jtreminio / dashtainer

MIT License
50 stars 3 forks source link

Xdebug on Linux needs a programmatic value for remote_host #2

Open jtreminio opened 6 years ago

jtreminio commented 6 years ago

Currently suggest using 192.18.0.1 to access host from within container.

This really only works when user does not have any other networks defined and is spinning up a Dashtainer project on a vanilla host. If any other networks defined that IP is no longer valid.

Using route | awk '/^default/ { print $2 }' we can find the gateway that can be used for Xdebug (and other services that must reach host!).

Windows and MacOS can use docker.for.mac.host.internal, docker.for.win.host.internal. Maybe create an entry in /etc/hosts for containers that need this?

apt-get install net-tools
&& echo $(route | awk '/^default/ { print $2 }') docker.for.linux.host.internal >> /etc/hosts
ntzm commented 6 years ago

As of docker 18.03 it's host.docker.internal for both windows and mac, there is an issue here for linux https://github.com/docker/for-linux/issues/264

jtreminio commented 6 years ago

Thanks @ntzm - looks like writing to /etc/hosts is a no-go since that file is mounted and any changes are immediately discarded.