diff --git a/CHANGELOG.md b/CHANGELOG.md
index c6629e5..e15c993 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,22 @@
# Changelog
+## 1.3.0 (2015-11-10)
+
+- Version updates
+ - boot2docker base box v1.9.0
+ - Docker v1.9.0
+ - Docker Compose v1.5.0 (now installed as a binary on Windows)
+- Default to **nfs2** on Mac and **smb2** on Windows
+- rsync
+ - Switching to vagrant-gatling-rsync for better rsync-auto performance
+ - Auto start gatling-rsync-auto **in background** (Mac only)
+- Revised vboxsf, smb and rsync settings
+- Fixed vagrant user account expiration (smb2 option)
+- Added a way to define individual mounts
+- Added "group=system" label to dns and vhost-proxy containers
+- Added support for authentication against docker hub
+- Fixed typo: vboxfs => vboxsf
+
## 1.2.1 (2015-10-28)
- Update path to shell scripts in README.md
diff --git a/README.md b/README.md
index 4ab69f0..a4fba67 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,12 @@
# Boot2docker Vagrant Box
Boot2docker Vagrant box for optimized Docker and Docker Compose use on Mac and Windows.
+
## What is this?
-This is a temporary solution to achieve better performance with synced folders and docker data volumes on Mac and Windows.
-The stock boot2docker currently mounts host volumes via the default VirtualBox Guest Additions (vboxfs) mode, which is terribly slow. Much better performance can be achieved with NFS, SMB or rsync.
+
+This is a temporary solution to achieve better performance with synced folders and docker data volumes on Mac and Windows.
+
+The stock boot2docker/docker-machine mounts host volumes via VirtualBox Guest Additions (vboxsf) mode, which is is terribly slow. Much better performance can be achieved with **nfs** (Mac), **smb** (Windows) or **rsync** (Mac and Windows).
## Prerequisites
@@ -11,10 +14,10 @@ The stock boot2docker currently mounts host volumes via the default VirtualBox G
2. [Vagrant](https://www.vagrantup.com/) 1.7.3+
3. [Babun](http://babun.github.io) - A Linux-type shell, **Windows only**
-Proceed to [Setup and usage](#setup) if you already have all prerequisites installed or prefer to install some/all manually.
+For best result and a clean setup it is recommended to remove any previous versions of VirtualBox, Vagrant, boot2docker, docker and docker-compose.
-Automatic **installation** and **updates** of prerequisites is available via the following one-liners.
-Make sure to stop all VirtualBox VMs prior to performing updates.
+Automatic **installation** and **updates** of prerequisites is available via the one-liners below.
+**Make sure to stop all VirtualBox VMs prior to performing updates.**
**Mac**
@@ -24,265 +27,46 @@ Prerequisites are installed using **brew/cask** (brew and cask will be installed
**Windows**
-**On Windows you will need a good Linux-type shell. [Babun](http://babun.github.io) is a great option. All automated scripts and instructions in this project assume using Babun shell and were not tested with other CYGWIN shells.**
+**All automated scripts and instructions in this project assume using Babun shell and are not tested with other shells.**
Prerequisites are installed using **babun** and **chocolatey** (chocolatey will be installed if missing).
-**Docker Compose will be installed natively on Windows via pip!**
-
-1. Download and install [Babun](http://babun.github.io)
-2. Run the following in babun
-
- ```
bash <(curl -s https://raw.githubusercontent.com/blinkreaction/boot2docker-vagrant/master/scripts/presetup-win.sh)
- ```
+
## Setup and usage
-### Automatic installation (Mac and Windows)
+### Automatic installation
-Run the following command within your `` (shared boo2docker VM for multiple projects, recommended) or `` (dedicated boot2docker VM) directory:
+Designate a root folder that the VM will have access to (e.g. `~/Projects`) and run there:
bash <(curl -s https://raw.githubusercontent.com/blinkreaction/boot2docker-vagrant/master/scripts/setup.sh)
-### Manual installation (Mac and Windows)
+### Manual installation
-1. Copy `Vagrantfile` and `vagrant.yml` files from this repo into your `` (shared boo2docker VM for multiple projects, recommended) or `` (dedicated boot2docker VM) directory.
-2. Rename `vagrant.yml.dist` to `vagrant.yml`
-3. Launch Terminal (Mac) or Babun (Windows)
-4. cd to ``, start the VM
+1. Copy `Vagrantfile` and `vagrant.yml` into a designated folder
+2. Inside the folder run
```
- cd
vagrant up
```
-5. Verify installation
+3. Verify your setup by checking docker client and server versions
- ```
+ ```
docker version
- docker-compose --version
```
-
-## Synced Folders options
-
-This box supports all [Synced Folder](http://docs.vagrantup.com/v2/synced-folders/) options provided by Vagrant:
-- vboxfs - native VirtualBox method, cross-platform, convenient and reliable, terribly slow
-- NFS - better performance and convenience for Mac
-- SMB - better performance and convenience for Windows (on par with NFS on Mac)
-- rsync - best performance, cross-platform, one-way only
-
-Follow the instructions in the `vagrant.yml` file to switch between different sync options.
-The best balance between performance and convenience can be achieved with NFS on Mac (default) and SMB on Windows (not default).
-
-Additional steps are required to get SMB or rsync to work on Windows. [See below](#synced-folders-win).
-
-In addition to the stock SMB synced folders option this box provides an experimental one: [SMB2](#synced-folders-smb2).
-With the **SMB2** option you will receive several "elevated command prompt" prompts which you accept.
-No need to enter usernames and passwords unlike the stock SMB option Vagrant ships with.
-
-If you use rsync, you'll have to run `vagrant rsync-auto` in a separate terminal to keep the files in sync as you make changes.
-
-
-### Mac
-
-Option comparison for Mac Drupal developers (using `time drush si -y` as a test case):
-- vboxfs: 6x (slowest)
-- NFS: 1.3x
-- rsync: 1x (fastest)
-
-NFS provides good performance and convenience. It is the default and recommended option on Mac.
-
-
-### Windows
-
-Option comparison for Windows Drupal developers (using `time drush si -y` as a test case):
-- vboxfs: 5x (slowest)
-- SMB: 2x
-- rsync: 1x (fastest)
-
-SMB provides good performance and convenience. It is the recommended option, but NOT the default one on Windows.
-
-**Enabling SMB**
-
-To use the SMB synced folder type:
-
-1. Stop the VM with: `vagrant halt`
-2. Choose `smb` as the sync type in the `vagrant.yml` file.
-3. Launch Git Bash as an administrator
-4. Start the VM: `vagrant up`
-
-While using SMB you have to control Vagrant from an elevated (run as admin) Git Bash shell.
-
-
-**SMB2 (experimental option)**
-
-This is an experimental option.
-Compared to **SMB**, **SMB2** does not require running vagrant as admin and does not prompt for username and password.
-You will receive several "elevated command prompt" prompts which you accept.
-Vagrant will automatically create a user, set correct file permissions, create the SMB share, and mount it.
-
-**Enabling rsync**
-
-rsync is not natively available on Windows.
-Git for Windows comes with Git Bash shell, which is based on [MinGW/MSYS](http://www.mingw.org/wiki/msys).
-MSYS has a package for rsync, which can be installed and accessed via Git Bash.
-
-To use rsync on Windows:
-
-1. Download and extract the content on this [archive](https://drive.google.com/open?id=0B130F0xKxOWCTUN1d3djZGZ0M2M&authuser=0) into the `bin` directory of your Git installation (e.g. `c:\Program Files (x86)\Git\bin\`).
-2. Choose `rsync` as the sync type in the `vagrant.yml` file.
-3. Provide an explicit list of folders to sync in the `vagrant.yml` file (`folders` sequence).
-4. Reload the VM: `vagrant reload`
-5. Run `vagrant rsync-auto` to keep the files in sync as you make changes.
-
-
-## VirtualBox VM settings
-
-Open `vagrant.yml` file and edit respective values.
-
-- `v.gui` - Set to `true` for debugging. This will unhide VM's primary console screen. Default: `false`.
-- `v.memory` - Memory settings (MB). Default: `2048`.
-- `v.cpus: 1` - number of virtual CPU cores. Default: `1`.
-
-Please note, VirtualBox works much better with a single CPU in most cases, this it is not recommended to change the `v.cpus` value.
-
-
-## Network settings
-
-The default box private network IP is `192.168.10.10`.
-To map additional IP addresses for use with multiple projects open `vagrant.yml` and ucomment respective lines:
-
-```yaml
-hosts:
- - ip: 192.168.10.11
- - ip: 192.168.10.12
- - ip: 192.168.10.13
-```
-
-Project specific `:` mapping for containers is done in via docker-compose in `docker-compose.yml`
-
-
-## vhost-proxy
-
-As an alternative to using dedicated IPs for different projects a built-in vhost-proxy container can be used.
-It binds to `192.168.10.10:80` (the default box IP address) and routes web requests based on the `Host` header.
-
-### How to use
-- Set `vhost_proxy: true` in your vagrant.yml file and do a 'vagrant reload'
-- Set the `VIRTUAL_HOST` environment variable for the web container in your setup (e.g. `VIRTUAL_HOST=example.com`)
-- Add an entry in your hosts file (e.g. `/etc/hosts`) to point the domain to the default box IP (`192.168.10.10`)
- - As an alternative see [Wildcard DNS](#dns) instructions below
-- Multiple domain names can be separated by comas: `VIRTUAL_HOST=example.com,www.example.com`
-
-Example docker run
-
-```
-docker run --name nginx -d -e "VIRTUAL_HOST=example.com" nginx:latest
-```
-
-Example docker-compose.yml entry
-
-```
-# Web node
-web:
- image: nginx:latest
- ports:
- - "80"
- environment:
- - VIRTUAL_HOST=example.com
-```
-
-Example hosts file entry
-
-```
-192.168.10.10 example.com
-```
-
-It is completely fine to use both the vhost-proxy approach and the dedicated IPs approach concurently:
- - `"80"` - expose port "80", docker will randomly pick an available port on the Docker Host
- - `"192.168.10.11:80:80"` - dedicated IP:port mapping
-
-
-## DNS and service discovery
-
-### DNS resolution
-
-The built-in `dns` container can be used to resolve all `*.drude` domain names to `192.168.10.10` (VM's primary IP address), where vhost-proxy listens on port 80.
-
-**Mac**
-
-```
-sudo mkdir -p /etc/resolver
-echo -e "\n# .drude domain resolution\nnameserver 192.168.10.10" | sudo tee -a /etc/resolver/drude
-```
-
-**Windows**
-
-On Windows add `192.168.10.10` as the primary DNS server and your LAN/ISP/Google DNS as secondary.
-
-
-### Service discovery
-
-The built-in `dns` container can also be used for local DNS based service discovery.
-You can define an arbitrary domain name via the `DOMAIN_NAME` environment variable for any container and it will be resolved to the internal IP address of that container.
-
-**Example**
-
-```
-docker run --name nginx -d -e "DOMAIN_NAME=my-project.web.docker" nginx:latest
-docker run busybox ping my-project.web.docker -c 1
-```
-
-```
-PING my_project.web.docker (172.17.42.8): 56 data bytes
-64 bytes from 172.17.42.8: seq=0 ttl=64 time=0.052 ms
-...
-
-```
-
-Multiple domain names can be separated by comas: `DOMAIN_NAME=my-project.web.docker,www.my-project.web.docker`
-
-## Tips
-
-### Automate DOCKER_HOST variable export
-
-This is only necessary for manual instllations. On Mac the [setup.sh](setup.sh) scripts takes care of this for you.
-
-Add the following in your .bashrc, .zshrc, etc. file to automate the environment variable export:
-
- # Docker (default for Vagrant based boxes)
- export DOCKER_HOST=tcp://localhost:2375
-
-If you also have `$(boot2docker shellinit)` there, then make sure those lines go BEFORE it, e.g.:
-
- # Docker (default for Vagrant based boxes)
- export DOCKER_HOST=tcp://localhost:2375
-
- # boot2docker shellinit
- $(boot2docker shellinit)
-
-This way if boot2docker is NOT running, your `DOCKER_HOST` will default to `tcp://localhost:2375`.
-Otherwise `$(boot2docker shellinit)` will overwrite the variables and set `DOCKER_HOST` to point to the boot2docker VM.
-
-### Vagrant control
-Vagrant can be controlled (e.g. `vagrant up`, `vagrant ssh`, `vagrant reload`, etc.) from the root directory of the Vagrantfile as well as from any subdirectory. This is very usefull when working with multiple projects in subdirectories.
-
-### Sublime Text 3 users
-Add this to your user settings (Sublime Text > Preferences > Settings - User):
-
- {
- "atomic_save": false
- }
-ST3 does not update the ctime extended file attribute when saving a file. This leads to NFS not seeing the changes in a file unless the file size changes as well (i.e. changing a single symbol in a file with ST3 will not be visible over NFS). The setting above fixes that.
+## Documentation
-
-## troubleshooting
+- [Synced folders](docs/synced-folders.md)
+- [VirtualBox VM settings](docs/vm-settings.md)
+- [Networking](docs/networking.md)
+- [Troubleshooting](docs/troubleshooting.md)
+- [Tips](docs/tips.md)
-See [Troubleshooting](docs/troubleshooting.md) section of the docs.
## License
diff --git a/VERSION b/VERSION
index 6085e94..f0bb29e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.2.1
+1.3.0
diff --git a/Vagrantfile b/Vagrantfile
index cb52504..32d18a5 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -2,7 +2,7 @@
@ui = Vagrant::UI::Colored.new
# Install required plugins if not present.
-required_plugins = %w(vagrant-triggers)
+required_plugins = ["vagrant-triggers", "vagrant-gatling-rsync"]
required_plugins.each do |plugin|
need_restart = false
unless Vagrant.has_plugin? plugin
@@ -52,7 +52,7 @@ if is_windows
smb_username = $vconfig['synced_folders']['smb_username']
smb_password = $vconfig['synced_folders']['smb_password']
- command_user = "net user #{smb_username} || net user #{smb_username} #{smb_password} /add"
+ command_user = "net user #{smb_username} || ( net user #{smb_username} #{smb_password} /add && WMIC USERACCOUNT WHERE \"Name='vagrant'\" SET PasswordExpires=FALSE )"
@ui.info "Adding vagrant user"
windows_elevated_shell command_user
@@ -98,7 +98,7 @@ Vagrant.configure("2") do |config|
config.vm.define "boot2docker"
config.vm.box = "blinkreaction/boot2docker"
- config.vm.box_version = "1.8.3"
+ config.vm.box_version = "1.9.0"
config.vm.box_check_update = true
## Network ##
@@ -118,28 +118,32 @@ Vagrant.configure("2") do |config|
## Synced folders configuration ##
synced_folders = $vconfig['synced_folders']
- # nfs: better performance on Mac
+ # nfs: Better performance on Mac
if synced_folders['type'] == "nfs" && !is_windows
+ @ui.success "Using nfs synced folder option"
config.vm.synced_folder vagrant_root, vagrant_mount_point,
type: "nfs",
mount_options: ["nolock", "vers=3", "tcp"]
config.nfs.map_uid = Process.uid
config.nfs.map_gid = Process.gid
- # nfs2: better performance on Mac, experimental
- elsif synced_folders['type'] == "nfs2" && !is_windows
+ # nfs2: Optimized NFS settings for even better performance on Mac, experimental
+ elsif ( synced_folders['type'] == "nfs2" || synced_folders['type'] == "default" ) && !is_windows
+ @ui.success "Using nfs2 synced folder option"
config.vm.synced_folder vagrant_root, vagrant_mount_point,
type: "nfs",
mount_options: ["nolock", "noacl", "nocto", "noatime", "nodiratime", "vers=3", "tcp"]
config.nfs.map_uid = Process.uid
config.nfs.map_gid = Process.gid
- # smb: better performance on Windows. Requires Vagrant to be run with admin privileges.
+ # smb: Better performance on Windows. Requires Vagrant to be run with admin privileges.
elsif synced_folders['type'] == "smb" && is_windows
+ @ui.success "Using smb synced folder option"
config.vm.synced_folder vagrant_root, vagrant_mount_point,
type: "smb",
smb_username: synced_folders['smb_username'],
smb_password: synced_folders['smb_password']
- # smb2: experimental, does not require running vagrant as admin.
- elsif synced_folders['type'] == "smb2" && is_windows
+ # smb2: Better performance on Windows. Does not require running vagrant as admin.
+ elsif ( synced_folders['type'] == "smb2" || synced_folders['type'] == "default" ) && is_windows
+ @ui.success "Using smb2 synced folder option"
if $vconfig['synced_folders']['smb2_auto']
# Create the share before 'up'.
@@ -159,28 +163,82 @@ Vagrant.configure("2") do |config|
config.vm.provision "shell", run: "always" do |s|
s.inline = <<-SCRIPT
mkdir -p vagrant $2
- mount -t cifs -o uid=`id -u docker`,gid=`id -g docker`,sec=ntlm,username=$3,pass=$4,dir_mode=0755,file_mode=0644 //$5/$1 $2
+ mount -t cifs -o uid=`id -u docker`,gid=`id -g docker`,sec=ntlm,username=$3,pass=$4,dir_mode=0777,file_mode=0666 //$5/$1 $2
SCRIPT
s.args = "#{vagrant_folder_name} #{vagrant_mount_point} #{$vconfig['synced_folders']['smb_username']} #{$vconfig['synced_folders']['smb_password']} #{host_ip}"
end
- # rsync: the best performance, cross-platform platform, one-way only. Run `vagrant rsync-auto` to start auto sync.
+ # rsync: the best performance, cross-platform platform, one-way only.
elsif synced_folders['type'] == "rsync"
+ @ui.success "Using rsync synced folder option"
+
+ # Construct and array for rsync_exclude
+ rsync_exclude = []
+ unless synced_folders['rsync_exclude'].nil?
+ for item in synced_folders['rsync_exclude'] do
+ rsync_exclude.push(item)
+ end
+ end
+
# Only sync explicitly listed folders.
- if (synced_folders['folders']).nil?
- @ui.warn "WARNING: 'folders' list cannot be empty when using 'rsync' sync type. Please check your vagrant.yml file."
+ if synced_folders['rsync_folders'].nil?
+ @ui.error "ERROR: 'folders' list cannot be empty when using 'rsync' sync type. Please check your vagrant.yml file."
+ exit
else
- for synced_folder in synced_folders['folders'] do
+ for synced_folder in synced_folders['rsync_folders'] do
config.vm.synced_folder "#{vagrant_root}/#{synced_folder}", "#{vagrant_mount_point}/#{synced_folder}",
type: "rsync",
- rsync__exclude: ".git/",
- rsync__args: ["--verbose", "--archive", "--delete", "-z", "--chmod=ugo=rwX"]
+ rsync__exclude: rsync_exclude,
+ rsync__args: ["--archive", "--delete", "--compress", "--whole-file"]
+ end
+ end
+ # Configure vagrant-gatling-rsync
+ config.gatling.rsync_on_startup = false
+ config.gatling.latency = synced_folders['rsync_latency']
+ config.gatling.time_format = "%H:%M:%S"
+
+ # Launch gatling-rsync-auto in the background
+ if synced_folders['rsync_auto'] && !is_windows
+ [:up, :reload, :resume].each do |trigger|
+ config.trigger.after trigger do
+ success "Starting background rsync-auto process..."
+ info "Run 'tail -f #{vagrant_root}/rsync.log' to see logs."
+ # Kill the old sync process
+ `kill $(pgrep -f rsync-auto) > /dev/null 2>&1 || true`
+ # Start a new sync process in background
+ `vagrant gatling-rsync-auto >> rsync.log &`
+ end
+ end
+ [:halt, :suspend, :destroy].each do |trigger|
+ config.trigger.before trigger do
+ # Kill rsync-auto process
+ success "Stopping background rsync-auto process..."
+ `kill $(pgrep -f rsync-auto) > /dev/null 2>&1 || true`
+ `rm -f rsync.log`
+ end
+ end
+ end
+ # vboxsf: reliable, cross-platform and terribly slow performance
+ elsif synced_folders['type'] == "vboxsf"
+ @ui.warn "WARNING: Using the SLOWEST folder sync option (vboxsf)"
+ config.vm.synced_folder vagrant_root, vagrant_mount_point
+ # Warn if neither synced_folder not individual_mounts is enabled
+ elsif synced_folders['individual_mounts'].nil?
+ @ui.error "ERROR: Synced folders not enabled or misconfigured. The VM will not have access to files on the host."
+ end
+
+ # Individual mounts
+ unless synced_folders['individual_mounts'].nil?
+ @ui.success "Using individual_mounts synced folder option"
+ for synced_folder in synced_folders['individual_mounts'] do
+ if synced_folder['type'] == 'vboxsf'
+ config.vm.synced_folder synced_folder['location'], synced_folder['mount'],
+ mount_options: [synced_folder['options']]
+ elsif synced_folder['type'] == 'nfs'
+ config.vm.synced_folder synced_folder['location'], synced_folder['mount'],
+ type: "nfs",
+ mount_options: [synced_folder['options']]
end
end
- # vboxfs: reliable, cross-platform and terribly slow performance
- else
- @ui.warn "WARNING: defaulting to the slowest folder sync option (vboxfs)"
- config.vm.synced_folder vagrant_root, vagrant_mount_point,
- mount_options: ["dmode=770", "fmode=660"]
end
# Make host home directory available to containers in /.home
@@ -231,14 +289,26 @@ Vagrant.configure("2") do |config|
SCRIPT
end
+ # Let users provide credentials to log in to Docker Hub.
+ if $vconfig['docker_registry_auth']
+ config.vm.provision "trigger", :option => "value" do |trigger|
+ trigger.fire do
+ info 'Authenticating with the Docker registry...'
+ system "docker -H localhost:2375 login"
+ end
+ end
+ config.vm.provision "file", source: "~/.docker/config.json", destination: ".docker/config.json"
+ end
+
# System-wide dnsmasq service for DNS discovery and name resolution
# Image: blinkreaction/dns-discovery v1.0.0
config.vm.provision "shell", run: "always", privileged: false do |s|
s.inline = <<-SCRIPT
echo "Starting system-wide DNS service... "
docker rm -f dns > /dev/null 2>&1 || true
- docker run -d --name dns -p $1:53:53/udp -p 172.17.42.1:53:53/udp --cap-add=NET_ADMIN \
- --dns 8.8.8.8 -v /var/run/docker.sock:/var/run/docker.sock \
+ docker run -d --name dns --label "group=system" \
+ -p $1:53:53/udp -p 172.17.42.1:53:53/udp --cap-add=NET_ADMIN --dns 8.8.8.8 \
+ -v /var/run/docker.sock:/var/run/docker.sock \
blinkreaction/dns-discovery@sha256:f1322ab6d5496c8587e59e47b0a8b1479a444098b40ddd598e85e9ab4ce146d8 > /dev/null
SCRIPT
s.args = "#{box_ip}"
@@ -252,7 +322,8 @@ Vagrant.configure("2") do |config|
s.inline = <<-SCRIPT
echo "Starting system-wide HTTP/HTTPS reverse proxy on $1... "
docker rm -f vhost-proxy > /dev/null 2>&1 || true
- docker run -d --name vhost-proxy -p $1:80:80 -p $1:443:443 -v /var/run/docker.sock:/tmp/docker.sock \
+ docker run -d --name vhost-proxy --label "group=system" -p $1:80:80 -p $1:443:443 \
+ -v /var/run/docker.sock:/tmp/docker.sock \
blinkreaction/nginx-proxy@sha256:1707c0fd2fa4f0e98a656f748a4edb8a04578e9dc63115acc23a05225f151e04 > /dev/null
SCRIPT
s.args = "#{box_ip}"
diff --git a/docs/networking.md b/docs/networking.md
new file mode 100644
index 0000000..bc6f973
--- /dev/null
+++ b/docs/networking.md
@@ -0,0 +1,97 @@
+# Networking
+
+
+## VM network settings
+
+The default box private network IP is `192.168.10.10`.
+To map additional IP addresses for use with multiple projects open `vagrant.yml` and ucomment respective lines:
+
+```yaml
+hosts:
+ - ip: 192.168.10.11
+ - ip: 192.168.10.12
+ - ip: 192.168.10.13
+```
+
+Project specific `:` mapping for containers is done in via docker-compose in `docker-compose.yml`
+
+
+## vhost-proxy
+
+As an alternative to using dedicated IPs for different projects a built-in vhost-proxy container can be used.
+It binds to `192.168.10.10:80` (the default box IP address) and routes web requests based on the `Host` header.
+
+### How to use
+- Set `vhost_proxy: true` in your vagrant.yml file and do a 'vagrant reload'
+- Set the `VIRTUAL_HOST` environment variable for the web container in your setup (e.g. `VIRTUAL_HOST=example.com`)
+- Add an entry in your hosts file (e.g. `/etc/hosts`) to point the domain to the default box IP (`192.168.10.10`)
+ - As an alternative see [Wildcard DNS](#dns) instructions below
+- Multiple domain names can be separated by comas: `VIRTUAL_HOST=example.com,www.example.com`
+
+Example docker run
+
+```
+docker run --name nginx -d -e "VIRTUAL_HOST=example.com" nginx:latest
+```
+
+Example docker-compose.yml entry
+
+```
+# Web node
+web:
+ image: nginx:latest
+ ports:
+ - "80"
+ environment:
+ - VIRTUAL_HOST=example.com
+```
+
+Example hosts file entry
+
+```
+192.168.10.10 example.com
+```
+
+It is completely fine to use both the vhost-proxy approach and the dedicated IPs approach concurently:
+ - `"80"` - expose port "80", docker will randomly pick an available port on the Docker Host
+ - `"192.168.10.11:80:80"` - dedicated IP:port mapping
+
+
+## DNS and service discovery
+
+### DNS resolution
+
+The built-in `dns` container can be used to resolve all `*.drude` domain names to `192.168.10.10` (VM's primary IP address), where vhost-proxy listens on port 80.
+
+**Mac**
+
+```
+sudo mkdir -p /etc/resolver
+echo -e "\n# .drude domain resolution\nnameserver 192.168.10.10" | sudo tee -a /etc/resolver/drude
+```
+
+**Windows**
+
+On Windows add `192.168.10.10` as the primary DNS server and your LAN/ISP/Google DNS as secondary.
+
+
+### Service discovery
+
+The built-in `dns` container can also be used for local DNS based service discovery.
+You can define an arbitrary domain name via the `DOMAIN_NAME` environment variable for any container and it will be resolved to the internal IP address of that container.
+
+**Example**
+
+```
+docker run --name nginx -d -e "DOMAIN_NAME=my-project.web.docker" nginx:latest
+docker run busybox ping my-project.web.docker -c 1
+```
+
+```
+PING my_project.web.docker (172.17.42.8): 56 data bytes
+64 bytes from 172.17.42.8: seq=0 ttl=64 time=0.052 ms
+...
+
+```
+
+Multiple domain names can be separated by comas: `DOMAIN_NAME=my-project.web.docker,www.my-project.web.docker`
diff --git a/docs/synced-folders.md b/docs/synced-folders.md
new file mode 100644
index 0000000..c7069f0
--- /dev/null
+++ b/docs/synced-folders.md
@@ -0,0 +1,42 @@
+# Synced Folders
+
+This box supports all [Synced Folder](http://docs.vagrantup.com/v2/synced-folders/) options provided by Vagrant
+as well two custom optimized options :
+- vboxsf - native VirtualBox method, cross-platform, convenient and reliable, terribly slow
+- nfs: better performance and convenience on Mac
+- nfs2: optimized nfs settings, experimental (default on Mac)
+- smb: better performance and convenience on Windows. Requires Vagrant to be run with admin privileges (not recommended).
+- smb2: does not require running vagrant as admin (default on Windows).
+- rsync: best performance, cross-platform platform, one-way only
+
+Follow the instructions in the `vagrant.yml` file to switch between different sync options.
+The best balance between performance and convenience can be achieved with **nfs2** on Mac (default) and **smb2** on Windows (default).
+
+If you use rsync on Windows, you'll have to run `vagrant gatling-rsync-auto` in a separate terminal to keep the files in sync as you make changes.
+This is automated on Mac with `rsync_auto` set to `true` in `vagrant.yml`.
+
+
+## Mac
+
+Option comparison for Mac Drupal developers (using `time drush si -y` as a test case):
+- vboxsf: 6x (slowest)
+- nfs: 1.3x
+- rsync: 1x (fastest)
+
+NFS provides good performance and convenience (used by default on Mac)
+
+
+## Windows
+
+Option comparison for Windows Drupal developers (using `time drush si -y` as a test case):
+- vboxsf: 5x (slowest)
+- smb: 2x
+- rsync: 1x (fastest)
+
+**smb** provides good performance and convenience (used by default on Windows)
+
+**smb vs smb2**
+
+Compared to **smb**, **smb2** does not require running vagrant as admin and does not prompt for username and password.
+You will receive several "elevated command prompt" prompts which you accept.
+Vagrant will automatically create a user, set correct file permissions, create the SMB share, and mount it.
diff --git a/docs/tips.md b/docs/tips.md
new file mode 100644
index 0000000..5581dcc
--- /dev/null
+++ b/docs/tips.md
@@ -0,0 +1,33 @@
+# Tips
+
+## Automate DOCKER_HOST variable export
+
+This is only necessary for manual instllations. [setup.sh](../scripts/setup.sh) script takes care of this for you.
+
+Add the following in your .bashrc, .zshrc, etc. file to automate the environment variable export:
+
+ # Docker (default for Vagrant based boxes)
+ export DOCKER_HOST=tcp://localhost:2375
+
+If you also have `$(boot2docker shellinit)` there, then make sure those lines go BEFORE it, e.g.:
+
+ # Docker (default for Vagrant based boxes)
+ export DOCKER_HOST=tcp://localhost:2375
+
+ # boot2docker shellinit
+ $(boot2docker shellinit)
+
+This way if boot2docker is NOT running, your `DOCKER_HOST` will default to `tcp://localhost:2375`.
+Otherwise `$(boot2docker shellinit)` will overwrite the variables and set `DOCKER_HOST` to point to the boot2docker VM.
+
+## Vagrant control
+Vagrant can be controlled (e.g. `vagrant up`, `vagrant ssh`, `vagrant reload`, etc.) from the root directory of the Vagrantfile as well as from any subdirectory. This is very usefull when working with multiple projects in subdirectories.
+
+## Sublime Text 3 users
+Add this to your user settings (Sublime Text > Preferences > Settings - User):
+
+ {
+ "atomic_save": false
+ }
+
+ST3 does not update the ctime extended file attribute when saving a file. This leads to NFS not seeing the changes in a file unless the file size changes as well (i.e. changing a single symbol in a file with ST3 will not be visible over NFS). The setting above fixes that.
diff --git a/docs/vm-settings.md b/docs/vm-settings.md
new file mode 100644
index 0000000..d9c7b1c
--- /dev/null
+++ b/docs/vm-settings.md
@@ -0,0 +1,10 @@
+
+# VirtualBox VM settings
+
+Open `vagrant.yml` file and edit respective values.
+
+- `v.gui` - Set to `true` for debugging. This will unhide VM's primary console screen. Default: `false`.
+- `v.memory` - Memory settings (MB). Default: `2048`.
+- `v.cpus: 1` - number of virtual CPU cores. Default: `1`.
+
+Please note, VirtualBox works much better with a single CPU in most cases, this it is not recommended to change the `v.cpus` value.
diff --git a/scripts/presetup-mac.sh b/scripts/presetup-mac.sh
index 065a056..d8edc49 100755
--- a/scripts/presetup-mac.sh
+++ b/scripts/presetup-mac.sh
@@ -1,7 +1,7 @@
#!/bin/bash
-DOCKER_VERSION=1.8.3
-DOCKER_COMPOSE_VERSION=1.4.2
+DOCKER_VERSION=1.9.0
+DOCKER_COMPOSE_VERSION=1.5.0
# Console colors
red='\033[0;31m'
diff --git a/scripts/presetup-ubuntu.sh b/scripts/presetup-ubuntu.sh
new file mode 100644
index 0000000..d231599
--- /dev/null
+++ b/scripts/presetup-ubuntu.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+DOCKER_VERSION=1.9.0
+DOCKER_COMPOSE_VERSION=1.5.0
+
+#-------------------------- Helper functions --------------------------------
+
+# Console colors
+red='\033[0;31m'
+green='\033[0;32m'
+yellow='\033[1;33m'
+NC='\033[0m'
+
+echo-red () { echo -e "${red}$1${NC}"; }
+echo-green () { echo -e "${green}$1${NC}"; }
+echo-yellow () { echo -e "${yellow}$1${NC}"; }
+
+if_failed ()
+{
+ if [ ! $? -eq 0 ]; then
+ if [[ "$1" == "" ]]; then msg="dsh: error"; else msg="$1"; fi
+ echo-red "dsh: $msg"
+ exit 1
+ fi
+}
+
+#-------------------------- Installation --------------------------------
+
+if [ -r /etc/lsb-release ]; then
+ lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
+ lsb_release="$(. /etc/lsb-release && echo "$DISTRIB_RELEASE")"
+fi
+
+if [[ $lsb_dist != 'Ubuntu' || $lsb_release < '14.04' ]]; then
+ echo-red "Sorry, this script only supports Ubuntu 14.04+"
+ exit 1
+fi
+
+echo-green "Installing Docker..."
+curl -sSL https://get.docker.com/ | sh && \
+sudo usermod -aG docker $(whoami) && \
+sudo docker version
+if_failed "Docker installation/upgrade failed."
+
+echo-green "Installing Docker Compose..."
+sudo curl -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && \
+sudo chmod +x /usr/local/bin/docker-compose && \
+docker-compose --version
+if_failed "Docker Compose installation/upgrade failed."
+
+echo-green "Adding a subnet for DockerBox..."
+ip_mask="192.168.10.1/24"
+# Make sure we don't do this twice
+if ! grep -q $ip_mask /etc/network/interfaces; then
+ cat > /tmp/dockerbox.ip.addr < /usr/local/bin/docker-compose
+chmod +x /usr/local/bin/docker-compose
# Git settings
echo "Adjusting git defaults"
diff --git a/vagrant.yml b/vagrant.yml
index 009fa3a..7654644 100644
--- a/vagrant.yml
+++ b/vagrant.yml
@@ -1,13 +1,17 @@
# Sync folders configuration
synced_folders:
- # nfs: better performance on Mac, recommended.
- # nfs2: optimized NFS settings, experimental.
- # smb: better performance on Windows. Requires Vagrant to be run with admin privileges.
- # smb2: experimental, does not require running vagrant as admin.
- # rsync: the best performance, cross-platform platform, one-way only. Run `vagrant rsync-auto` to start auto sync.
- # When using rsync sync type the "folders" list below is mandatory.
- # vboxfs (or leave empty): best compatibility and ease of setup, but poor performance.
- type: 'nfs2'
+ # vboxsf - native VirtualBox method, cross-platform, convenient and reliable, terribly slow
+ # nfs: better performance and convenience on Mac
+ # nfs2: optimized nfs settings, experimental (default on Mac)
+ # smb: better performance and convenience on Windows. Requires Vagrant to be run with admin privileges (not recommended).
+ # smb2: does not require running vagrant as admin (default on Windows).
+ # rsync: best performance, cross-platform platform, one-way only
+ # Run `vagrant rsync-auto` to start auto sync.
+ # When using rsync sync type the "rsync_folders" list below is mandatory.
+ # vboxsf: best compatibility and ease of setup, but poor performance.
+ # default: defaults to nfs2 on Mac and smb2 on Windows.
+ # '': disable synced folders. Useful in case you want to use 'individual_mounts' option below.
+ type: 'default'
# smb_user, smb_password - The username and password used for authentication to mount the SMB mount.
# This is usually your Windows username and password, unless you created a dedicated user for vagrant.
# If using the 'smb2' type above the user and share will be configured automatically.
@@ -19,10 +23,30 @@ synced_folders:
# List of folders to sync with rsync. These should be subfolder names within the folder (e.g. "drupal7")
# Uncomment and add folders per the example below as neccessary.
# Note: you'll have to run `vagrant rsync-auto` in the background to keep the files in sync as you make changes
- folders:
+ rsync_folders:
#- "projectA" # rsync projectA folder
#- "projectB" # rsync projectB folder
#- "" # rsync the whole folder. WARNING: don't do this if your folder is big.
+ # Coalescing threshold in seconds for https://github.com/smerrill/vagrant-gatling-rsync
+ rsync_latency: 0.5
+ # Start rsync-auto automatically (Mac only for now)
+ rsync_auto: true
+ # Patterns excluded from rsync. Passed as --exclude to rsync.
+ rsync_exclude:
+ - ".git/"
+ #- "files/"
+ # List of folders to mount individually. This is really only needed in the case where you want a container to write
+ # something back to the Host OS. If that describes your situation, use type = vboxsf. If you just want more control
+ # over what's mounted, go with type = nfs, which is much faster.
+ individual_mounts:
+ #- location: './logs'
+ # mount: '/home/docker/logs'
+ # type: 'vboxsf'
+ # options: 'uid=501,gid=20'
+ #- location: './logs'
+ # mount: '/home/docker/logs'
+ # type: 'nfs'
+ # options: 'nolock,vers=3,tcp'
# VirtualBox VM settings
v.gui: false # Set to true for debugging. Will unhide VM's primary console screen.
@@ -40,6 +64,11 @@ ip:
#- 192.168.10.12
#- 192.168.10.13
+# Registry authentication. If your machine uses a private image, you must log in
+# to the registry before running docker-machine up. This is especially useful
+# when combined with compose_autostart: true.
+docker_registry_auth: false
+
# Automatically start containers if docker-compose.yml is present in the current directory (default: false).
compose_autostart: false