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 - xDebug with PHPStorm

If you enable xdebug in your server every time we run a script in PHP is going to send the information to the listener, the Listener in our case is PHPStorm. First of all you must have your PHP image up and running, but sadly you cant use the official one, you will need to build your own image, you can use this small script that I have wrote

Docker - how to run compass watch

Compass watch compiles sass or scss files using compass open-source CSS Authoring Framework. The way mentioned in this blog is config compass in docker-compose so that every time any sass changed, compass watch will run automatically. 

First, you need to configure your folders in a config.rb file, placed on the sass root folder. Here's an example folder structure, and its corresponding config.rb file.


So the config.rb should set like below:

Docker - use drush

There are 2 ways to use drush. The first one is install drush in drupal container. Every time you need to run drush, you ssh drupal container and run the command from that. The second one is to pull the drush image and run the drush command with "docker run".

Let's have a look at the first way. If you are using Drupal 7, you may install drush 6 in your Drupal container by adding the followings into Dockerfile.

Setup docker environment on Mac

Install docker-toolbox

Docker introduces docker-toolbox for installing docker, docker-compose, docker-machine. In my understanding, docker-machine can be considered as a replacement and a upgraded version of boot2docker. It will allow you to create separated virtualboxes for different projects. Docker-compose is a script which consist of several docker containers. Each docker container can be built with an independent Dockerfile.

Docker file structure