I’ve recently completed a refresher on Docker. Whilst working through this excellent MEAN stack setup with Angular 2 and Docker compose tutorial I realised that despite the docker compose setup being all present and correct my references to localhost were never gonna work correctly.
I’ve a number of Virtualbox VMs on my laptop that I needed to keep in place so the easiest option for me to get up and running with Docker was to install Docker Toolbox. Once installed, a Virtualbox VM running Boot2Docker (a cut down Linux distro) serves the Docker machine/env. I guess the assigned IP can differ but mine rolled out at 192.168.99.100 which means that any Containers spun up will sit on a port through this VMs IP address. Which is fine apart from when you’re working through tutorials or anything that expects your Docker setup on localhost.
So how can I set the VM as localhost? After thinking about HOSTS files and –add–host which didn’t seem to work it occurred to me that Virtualbox will allow for port forwarding. A quick addition to Virtualboxes rules and my Dev environment was up and running.