This technique is only suitable for Docker for Mac Beta. This requires the use of pfctl
to add ip/port forwarding and the /etc/hosts
file to setup the domain, and both of which require sudo
to run. This technique is required due to the fact that Docker only makes the containers accessible locally through the use of localhost and a random port. There reasoning beyond this has to do with Apple application sandboxing, but obviously is not ideal for most developers. Lastly, this will likely not work after a reboot so you will need to rerun the pfctl command. If you have several domains to worry about I'd suggest you setup a startup script in ruby or python to rerun the commands each time.
Please proceed with caution I'm not an expert on pfctl, though I don't foresee any major issues here. If anyone has a better way of doing this please share it and I'll update this document.
Below are a set of steps required to forward an ip