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
This commit is contained in:
Matthew Olenik 2018-05-08 21:10:54 -07:00 committed by Brian Cain
parent 5ca95c9e5a
commit 428eb3ed93
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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