はじめに
Mac/windows/linux側(ホスト)とVagrant側(ゲスト)間でファイルのやり取りを行う場合に、VagrantではSYNCED機能を用意しています。そのため、ftpなどのソフトを介してデータのやり取りを行う必要がなくなります。
またパフォーマンス面もVartualBoxの共有フォルダ機能や、FTPソフトよりもベンチマークで早い結果がでています。
SYNCED機能を使うことで、開発はホストPCで行い、実行はVagrant側のゲストで実行することが簡単にできるようになります。
公式ドキュメント※Synced Folder
http://docs.vagrantup.com/v2/synced-folders/
Vagrantfileの設定(共有/同期)
共有は設定を行わない場合もデフォルトでホストのVagrantfileが置いてあるディレクトリとVagrantの/vagrantが同期状態にあります。
Vagrantfileのsynced_folder設定を変更することで任意に指定することが可能になります。
synced_folderフォーマット
フォーマット:
config.vm.synced_folder “ホストPATH”, “ゲストPATH(Vagrant側)”
例:
config.vm.synced_folder “src/”, “/srv/website”
http://docs.vagrantup.com/v2/synced-folders/basic_usage.html
この場合、ホストのsrcディレクトリとゲストのsrv/websiteディレクトリで同期されます。
synced_folderのオプション
公式ドキュメントにオプションの詳細が記載されています。
create (boolean) – If true, the host path will be created if it does not exist. Defaults to false.
disabled (boolean) – If true, this synced folder will be disabled and won’t be setup. This can be used to disable a previously defined synced folder or to conditionally disable a definition based on some external factor.
group (string) – The group that will own the synced folder. By default this will be the SSH user. Some synced folder types don’t support modifying the group.
mount_options (array) – A list of additional mount options to pass to the mount command.
owner (string) – The user who should be the owner of this synced folder. By default this will be the SSH user. Some synced folder types don’t support modifying the owner.
type (string) – The type of synced folder. If this is not specified, Vagrant will automatically choose the best synced folder option for your environment. Otherwise, you can specify a specific type such as “nfs”.
http://docs.vagrantup.com/v2/synced-folders/basic_usage.html
createオプション
ホストパスが存在しない場合にホストのパスを自動作成する場合に設定します。デフォルトはfalse設定です。
指定方法:
config.vm.synced_folder “src/”, “/srv/website”, create: true
disabledオプション
同期を無効化にする場合に設定します。デフォルトはfalse設定です。
指定方法:
config.vm.synced_folder “src/”, “/srv/website”, disabled: true
groupオプション
ディレクトリを所有するグループを設定します。デフォルトはSSHユーザ(vagrant)です。
指定方法:
config.vm.synced_folder “src/”, “/srv/website”, group: “root”
普通ownerと合わせて使用します
config.vm.synced_folder “src/”, “/srv/website”, group: “root”, owner: “root”
mount_optionsオプション
mountのオプションを設定します。配列でオプションを渡します。デフォルトは空です。
指定方法:
mount_options: ["dmode=777", "fmode=777"]
ディレクトリ・ファイルのパーミッションを777設定にしてます
ownerオプション
ディレクトリを所有する所有者を設定します。デフォルトはSSHユーザ(vagrant)です。
指定方法:
config.vm.synced_folder “src/”, “/srv/website”, owner: “root”
typeオプション
同期化されたディレクトリの種類を設定します。vagrantは自動的に環境にあったタイプを設定してくれます。
typeは4種類あり、virtualbox,rsync,nfs,smbです。
virtualboxはvirtualbox付属の共有機能を使い、smbはwindows専用、smbはmac/linux専用となります。
そのためmacの場合はnfsかrsyncを使うことになります。virturalboxは無視しておきます。
virtualbox:
http://docs.vagrantup.com/v2/synced-folders/virtualbox.html
rsync:
http://docs.vagrantup.com/v2/synced-folders/rsync.html
nfs:
http://docs.vagrantup.com/v2/synced-folders/nfs.html
smb:
http://docs.vagrantup.com/v2/synced-folders/smb.html
指定方法:
config.vm.synced_folder “src/”, “/srv/website”, type: “nfs”
typeオプションのrsync設定
typeをrsyncにした場合、linuxコマンドのrsyncを使って同期を行います。
https://download.samba.org/pub/rsync/rsync.html
同期はホスト側でvagrant up / vagrant reload / vagrant rsync / vagrant provision のいずれかのコマンドで行います。
config.vm.synced_folder “src/”, “/srv/website”, type: “rsync”
rsyncコマンドでパラメータとして渡しているデフォルト値は[“–verbose”, “–archive”, “–delete”, “-z”, “–copy-links”]になります。
rsyncのその他設定情報についてはドキュメントを参照ください
http://docs.vagrantup.com/v2/synced-folders/rsync.html
coffee-break
Don't write code that useless.
1日5杯はコーヒー、カフェオレ飲みます。狭心症のため安静にします☆松本 雄貴
Kotlinでサービスリリース目指す!
iOSでチャットアプリ作成中。自然言語解析LSIを習得中
Mac / Android・iOS / Rails / Oracle
2017年 Lpic L2取得
2012年 Android技術者資格取得
2010年 OracleMasterGold10g取得
2008年 CCNAQiitaもたまに投稿
https://qiita.com/y-matsumoto東京近郊で常駐開発探してる方はこちらよりご連絡ください
SES企業でパートナー会社を探している企業様はこちらよりご連絡ください
スプリットカメラ iOS / Android
音声認識で聞いた日付から曜日当てアプリ Android
ソーシャルタイマー Android
カテゴリー
- ActiveRecord (2)
- Android (52)
- AndroidStudio (10)
- Ansible (1)
- AWS (1)
- Bash (18)
- Blog (7)
- BootStrap (1)
- CentOS (16)
- Chef (1)
- css (2)
- Eclipse (5)
- error (1)
- Facebook (2)
- Firebase (1)
- FuelPHP (16)
- Git (22)
- GitHub (3)
- Gradle (2)
- GraphAPI (1)
- Grunt (1)
- heroku (2)
- illustrator (1)
- iOS (17)
- Java (4)
- Jenkins (1)
- jQuery (3)
- Kotlin (2)
- Mac (22)
- nginx (1)
- Node.js (3)
- peco (1)
- php (5)
- Python (1)
- Rails (16)
- Ruby (11)
- shell (1)
- SNS (1)
- Swift (2)
- tmux (2)
- Vagrant (6)
- Vim (6)
- windows (2)
- WordPress (3)
- zsh (4)
- フリーランス (1)
- ライブラリ (1)
- 勉強会 (2)
- 宣伝 (1)
- 未分類 (2)
最近の投稿
- [MAC]HighSierraでgitプッシュエラー「Unable to negotiate with xxx.xxx.xxx.xxx port xx: no matching cipher found. Their offer: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se fatal: Could not read from remote repository.」
- [iOS]iOS11からFacebook,Twitter連携(シェアなど)廃止の対応方法
- [iOS]速報2017AppleSpecialEventのiOS11、iPhone8など発表内容について
- [iOS][Firebase]The default Firebase app has not yet been configured. Add `[FIRApp configure];
- [iOS]2017年9月リリースのiOS11で開発者が対応するべきこと
- 今人気の現金化サービスCASH(キャッシュ)を使ったレビュー
- [Pandoc][Mac]pandocでmarkdownからwordファイル作成
- [Android]映画サマーウォーズの聞いた日付(誕生日)から曜日当てをアプリ音声認識で簡単に実現
- [Android]起動しているActivityを取得するadb shell コマンド
- [Android][Kotlin]kotlin学習で参考になるサイト一覧
アーカイブ
- 2018年5月
- 2017年9月
- 2017年8月
- 2017年7月
- 2017年6月
- 2017年5月
- 2017年2月
- 2017年1月
- 2016年12月
- 2016年7月
- 2016年6月
- 2016年1月
- 2015年12月
- 2015年11月
- 2015年10月
- 2015年9月
- 2015年8月
- 2015年7月
- 2015年6月
- 2015年5月
- 2015年4月
- 2015年3月
- 2015年2月
- 2015年1月
- 2014年12月
- 2014年11月
- 2014年6月
- 2014年5月
- 2014年4月
- 2014年3月
- 2014年2月
- 2014年1月
- 2013年12月
- 2013年11月
- 2013年9月
- 2013年8月
- 2013年7月
- 2013年6月
- 2013年5月
- 2013年4月
- 2013年3月
- 2013年2月
- 2013年1月
- 2012年12月
- 2012年10月
- 2012年5月
- 2010年6月
エントリ