Docker - Use docker-machine on MAC with VPN

×

Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 569 of /homepages/46/d762693627/htdocs/dc/includes/menu.inc).
Docker - Use docker-machine on MAC with VPN

I use docker-machine on Mac and also need to connect company VPN from time to time. However, every time I connect to VPN, all docker machines' status turn to TIME OUT. Before I find this solution, I can only remove all docker machines and restart them all. It's really time comusing. 

I solved it changing the subnet of the VirtualBox host-only network.

 

First to remove all time out docker machines by the following command:

docker-machine rm machineName

Then recreate them by the command below

docker-machine create --driver virtualbox --virtualbox-hostonly-cidr "192.168.34.100/24" machineName

To customize the host only adapter, you can use the --virtualbox-hostonly-cidr flag. This will specify the host IP and Machine will calculate the VirtualBox DHCP server address (a random IP on the subnet between .1 and .25) so it does not clash with the specified host IP. Machine will also specify the DHCP lower bound to .100 and the upper bound to .254. For example, a specified CIDR of 192.168.24.1/24 would have a DHCP server between 192.168.24.2-25, a lower bound of 192.168.24.100 and upper bound of 192.168.24.254.

blog tag: