Skip to content

Commit

Permalink
implement host_mount_mode, #375
Browse files Browse the repository at this point in the history
  • Loading branch information
EugenMayer committed May 8, 2017
1 parent be2a57c commit f11ef9c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
docker-sync (0.4.3)
docker-sync (0.4.4.beta1)
daemons (~> 1.2, >= 1.2.3)
docker-compose (~> 1.0, >= 1.0.2)
dotenv (~> 2.1, >= 2.1.1)
Expand Down
2 changes: 2 additions & 0 deletions example/docker-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ syncs:
# the contents of this directory will be synchronized to the Docker volume with the name of this sync entry ('default-sync' here)
src: './default-data/'

# this is only available if you use docker-for-mac edge for now
host_disk_mount_mode: 'cached' # see https://github.com/moby/moby/pull/31047
# other unison options can also be specified here, which will be used when run under osx,
# and ignored when run under linux

Expand Down
5 changes: 4 additions & 1 deletion lib/docker-sync/sync_strategy/native_osx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def start_container
env['OWNER_UID'] = @options['sync_userid'] if @options.key?('sync_userid')
end

host_disk_mount_mode = '' # see https://github.com/moby/moby/pull/31047
host_disk_mount_mode = ":#{@options['host_disk_mount_mode']}" if @options.key?('host_disk_mount_mode')

additional_docker_env = env.map{ |key,value| "-e #{key}=\"#{value}\"" }.join(' ')
running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
if running == ''
Expand All @@ -65,7 +68,7 @@ def start_container
run_privileged = '--privileged' if @options.key?('max_inotify_watches') #TODO: replace by the minimum capabilities required
say_status 'ok', 'Starting precopy', :white if @options['verbose']
# we just run the precopy script and remove the container
cmd = "docker run --rm -v #{volume_app_sync_name}:/app_sync -v #{host_sync_src}:/host_sync -e HOST_VOLUME=/host_sync -e APP_VOLUME=/app_sync -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} #{additional_docker_env} #{run_privileged} --name #{container_name} #{@docker_image} /usr/local/bin/precopy_appsync"
cmd = "docker run --rm -v #{volume_app_sync_name}:/app_sync -v #{host_sync_src}:/host_sync#{host_disk_mount_mode} -e HOST_VOLUME=/host_sync -e APP_VOLUME=/app_sync -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} #{additional_docker_env} #{run_privileged} --name #{container_name} #{@docker_image} /usr/local/bin/precopy_appsync"
`#{cmd}` || raise('Precopy failed')
say_status 'ok', 'Starting container', :white if @options['verbose']
# this will be run below and start unison, since we did not manipulate CMD
Expand Down

0 comments on commit f11ef9c

Please sign in to comment.