File syncing when guest needs to write back to host (ie. bundle installing / updating)
schlenks opened this issue · comments
How do you handle this with your script?
I recently needed to do a bundle update on a particular gem we use, and while the update worked within the guest environment, it didn't update the file in the host environment where the code is stored. When you're using your scripts how do you handle cases where you may need to write something back to the file system and use it? (So beyond just a bundle install/update that writes to the Gemfile.lock, also for instance writing to a file for a rake task etc.)
Thanks.
d.
One of the known limitations of docker-osx-dev is that the sync works one-way only. This is because docker-osx-dev uses rsync under the hood, and rsync does only one-way syncing. We've had #22 open for a while to see if anyone wants to explore unison, but I haven't seen any progress on that front.
If having to sync files from the guest back to the host is a rare occasion, then you can use the docker cp
command to do it manually. For example, if your container was called my-rails-app
, you could do the following:
docker cp my-rails-app:/src/Gemfile.lock Gemfile.lock
However, if you have to sync files from the guest back to the host on a frequent basis, then docker-osx-dev probably isn't the best tool for the job. In that case, you may want to look at some of the alternatives that provide a two-way sync (albeit, usually at the cost of speed).
@brikis98 awesome, it's fairly infrequent at this time that we need to write back, your suggestion is perfect. 💯
thank you.
Also creating rails migrations is really annoying that way:
- Stop docker-osx-dev to prevent deleting migration file right after its creation.
docker exec my-rails-app rails g migration migration_name
docker cp my-rails-app:/src/db/migrate db
- Start docker-osx-dev to sync following changes in the migration file.
- Edit the migration file.
- Stop docker-osx-dev to prevent rollback of changes in
schema.rb
right after the migration run. docker exec my-rails-app rake db:migrate
docker cp my-rails-app:/src/db/schema.rb db
- Start docker-osx-dev for futher development.
@feymartynov: Yea, I ran into something similar with having to update a Gemfile.lock
file after running bundle update
, and I agree, it's a pain. Unfortunately, I'm not sure of a good solution until someone has a chance to take a crack at #22.