If you use Cisco Anyconnect VPN on your Mac OSX machine you would have found your experience with docker using boot2docker not working at times. The basic issue is that the Cisco Anyconnect VPN rewrites the routing rules which map the boot2docker Virtual box network interfaces.
The fix that has worked better for me in the last few days has been to not use boot2docker, but instead to use docker-machine to create a VMWare fusion based docker VM.
So to try out this approach first ensure that you have VMWare Fusion installed. Then install docker and docker-machine. Docker and docker-machine command line can be installed using homebrew:
brew install docker brew install docker-machine
Once the VMWare fusion, docker and docker-machine are in place, then use docker-machine to create a docker host using VMWare fusion this way:
docker-machine create -d vmwarefusion
Once the Host is properly created, verify that it is in a running state using docker-machine:
That is essentially it, to use this shiny new docker host ensure that the appropriate environment variables are set in the shell:
eval "$(docker-machine env fusion)"
and your docker commands should work with or without VPN connectivity:
docker ps -a