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