Allow a container running through the docker to connect to the Mysql or XDEBUG port on the parent OS without using the IP address assigned by OSX DHCP?

I have the following setup:

  • OSX runs MySQL, listening to all network adapters on port 3306
  • XDEBUG has activated IDE listening on port 9000 on the OSX base system.
  • host of the docking machine running on an OSX system with ip 192.168.99.100 host
  • A debian-based docker container with the mysql client running on the docker host and HHVM running on xdebug, which wants to connect to a successful remote host on port 9000.

Often IP addresses often change in the OSX system due to the destination via DHCP, so I want the docker container to somehow get to the mysql server, regardless of what IP address is assigned to the OSX network adapters (without manual updating) . Also, I need a stable ip. I can provide the HHVM server.ini host-host file for Xdebug.

When starting the base Linux system, this is not a problem, since the docker host and the actual native computer that works with the docker are the same. In addition, there are several ways that the container can find out about the host IP address, so the problem does not get into the docker host server.

However, in OSX running a docking machine, the host is not a native OSX system, but instead is a virtual machine running in a virtual box (assuming you use the vb driver ,?).

The only thing I could think of was to send a request for 3306 to the docker host (192.168.99.100, which never changes) to the OSX 3306 port. Then the container will go to the dock machine host for Mysql queries, IF this works, I could rinse and repeat for any port I that I need to bind, like xdebug on port 9000.

Does anyone know how to do this or is there another suggestion?

+7
docker virtualbox docker-machine
source share
1 answer

Identified the output without the need for any changes that provide a consistent ip for connecting to the underlying OSX system. The docker machine sets things up in such a way as to make this possible.

  • The Docker machine creates a virtual virtual machine with two network adapters, one configured as a host and the other as NAT. I don't know why he creates 2, but
  • The host-only adapter provides OSX ip 192.168.99.1, and the various virtual machines using it receive addresses starting at 192.168.99.100. However, inside a VM network, you cannot use the address 192.168.99.1 to access ports on the parent OSX system (not sure why, but guess that the host is only for communication between virtual machines).
  • The NAT network adapter is installed so that OSX receives ip 10.0.2.2 and the VM receives 10.0.2.15. Using NAT, you can switch to the OSX system in 10.0.2.2 both from the virtual machine of the docking station host and from containers running on the host.

Since this address 10.0.2.2 for the OSX machine does not change (unless you insert the network settings of the virtual box), bingo got what I need.

+18
source share

All Articles