Working with docker on a laptop testing configuration of containers has some of the same annoyances as working with other configuration managment tools and testing frameworks like test-kitchen, chef, ansible etc…
It takes forever to download dependencies. I might test some infrastructure code using vagrant or test-kitchen many many times a day and it sucks having to download apt packages from mirrors that time out or get bogged down randomly. Previously I had used a test-kitchen plugin to deal with that which I’ll cover in another post. In this I’m going to go over some simple hacks I’ve managed to get working for speeding up building of docker images using docker for mac beta.
See this forum thread in regards to the ongoing headaches with networking in docker for mac beta. Link
I was trying a bunch of ways to do this and just settled on the alias on lo0.
I just added this to my bash alias.
My use case was that I am running apt-cacher-ng on my mac natively. Using just a brew install apt-cacher-ng and running it as a service all the time. This speeds up test-kitchen and other configuration management tool testing.
The contents of detect-apt-proxy.sh are as follows.
Then when building my docker images…
This allows me to run the cacher locally and programmatically check for it inside the container and set the apt proxy options. This also works on Linux or docker-machine just leave off the build-arg for HOST_IP and it will use the older method of grabbing the gateway interface instead of the aliased interface…. This should in theory work with xhyve but the gateway interface is somehow hidden or locked down from the vm… Some insight on why you can’t access the gateway interface in xhyve vs virtualbox would be nice…