To connect to the host system from inside a container, setup a bridge network with a static IP address accessible from within the container.
For example, if your host system is Mac OS X:
- Go into Network under System Preferences.
- Click on the gear icon and choose Manage Virtual Interfaces.
- Click on the + button and choose New Bridge.
- Give it a name and do NOT include any other interfaces on your system.
- Click Create. It will appear in the list of your interfaces on the left in the Network panel.
- Click on it, and change Configure IPv4 from Using DHCP to Manually.
- Enter an IP that will not conflict with any network you might connect to into the IP Address field. Click Apply.
This works because as your traffic exits the container, the normal OSX routing rules are applied, and that IP address is locally available.