From 428eb3ed939cefbd94731b0e01ccf88fe906ce2e Mon Sep 17 00:00:00 2001 From: Matthew Olenik Date: Tue, 8 May 2018 21:10:54 -0700 Subject: [PATCH] Support Docker volume consistency for synced folders Adds the `docker_consistency` option, which sets the Docker volume consistency level. This can be used to greatly improved synced folder performance, especially on macOS. See for details: moby/moby#31047 --- plugins/providers/docker/synced_folder.rb | 5 ++++- website/source/docs/docker/basics.html.md | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/providers/docker/synced_folder.rb b/plugins/providers/docker/synced_folder.rb index e18682586..ca3829841 100644 --- a/plugins/providers/docker/synced_folder.rb +++ b/plugins/providers/docker/synced_folder.rb @@ -21,7 +21,10 @@ module VagrantPlugins host_path = data[:hostpath] guest_path = data[:guestpath] - machine.provider_config.volumes << "#{host_path}:#{guest_path}" + # Append consistency option if it exists, otherwise let it nil out + consistency = data[:docker_consistency] + consistency &&= ":" + consistency + machine.provider_config.volumes << "#{host_path}:#{guest_path}#{consistency}" end end end diff --git a/website/source/docs/docker/basics.html.md b/website/source/docs/docker/basics.html.md index e3846d71b..521a4d685 100644 --- a/website/source/docs/docker/basics.html.md +++ b/website/source/docs/docker/basics.html.md @@ -75,6 +75,16 @@ on folders synced with a docker container. Private and public networks are not currently supported. +### Volume Consistency + +Docker's [volume consistency](https://github.com/moby/moby/pull/31047) setting can be specified using the `docker_consistency` option when defining a synced folder. This can +[greatly improve performance on macOS](https://docs.docker.com/docker-for-mac/osxfs-caching). An example is shown using the `cached` and `delegated` settings: + +``` +config.vm.synced_folder "/host/dir1", "/guest/dir1", docker_consistency: "cached" +config.vm.synced_folder "/host/dir2", "/guest/dir2", docker_consistency: "delegated" +``` + ## Host VM If the system cannot run Linux containers natively, Vagrant automatically spins