{"id":639,"date":"2020-05-25T08:52:43","date_gmt":"2020-05-24T23:52:43","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2020\/05\/25\/vagrant-docker-mac"},"modified":"2022-10-28T21:39:01","modified_gmt":"2022-10-28T12:39:01","slug":"vagrant-docker-mac","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2020\/05\/25\/vagrant-docker-mac\/","title":{"rendered":"Docker for Mac\u306e\u4ee3\u308f\u308a\u306b\u3001Vagrant + Docker\u3067\u958b\u767a\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b"},"content":{"rendered":"

\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u5185\u5c71\u3067\u3059\u3002\u6700\u8fd1\u306f\u5bb6\u306b\u5f15\u304d\u3053\u3082\u3063\u3066\u3001\u3069\u3046\u68ee\u3068\u30b9\u30d7\u30e9\u30c8\u30a5\u30fc\u30f3\u3092\u697d\u3057\u3093\u3067\u3044\u307e\u3059\u3002<\/p>\n

\u4eca\u56de\u306f\u3001Vagrant + Docker\u3067\u958b\u767a\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u624b\u9806\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n

\u6982\u8981<\/h2>\n

Docker for Mac \u306f\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u60aa\u3044\u305f\u3081\u3001\u958b\u767a\u52b9\u7387\u306b\u60aa\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u539f\u56e0\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n

https:\/\/forums.docker.com\/t\/file-access-in-mounted-volumes-extremely-slow-cpu-bound\/8076\/158<\/a><\/p>\n

Docker\u81ea\u4f53\u304c\u9045\u3044\u308f\u3051\u3067\u306f\u306a\u3044\u305f\u3081\u3001Linux\u4e0a\u3067\u52d5\u304b\u3057\u305f\u5834\u5408\u306f\u3001\u554f\u984c\u306b\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n

\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001Docker for Mac\u306e\u4ee3\u308f\u308a\u306b\u3001Vagrant\u3067\u52d5\u4f5c\u3055\u305b\u3066\u3044\u308bLinux\u4e0a\u3067Docker\u3092\u4f7f\u3044\u3001\u958b\u767a\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u624b\u9806\u306f\u3001\u4ee5\u4e0b\u306e3\u30b9\u30c6\u30c3\u30d7\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

    \n
  1. VirtualBox\u3068Vagrant\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/li>\n
  2. mutagen\u3067\u30d5\u30a1\u30a4\u30eb\u540c\u671f\u3059\u308b<\/li>\n
  3. Docker\u3092\u8d77\u52d5\u3059\u308b<\/li>\n<\/ol>\n

    VirtualBox \u3068 Vagrant\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h2>\n

    Homebrew\u3092\u4f7f\u7528\u3057\u3088\u3046\u3057\u3066\u3001\u5fc5\u8981\u306a\u30c4\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n

    https:\/\/brew.sh\/<\/a><\/p>\n

    VirtualBox\u3068Vagrant\u3068Ubuntu\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n

    $ brew cask install virtualbox\n$ brew cask install vagrant\n$ vagrant box add ubuntu\/xenial64<\/code><\/pre>\n

    Docker\u3068mutagen(\u5f8c\u8ff0)\u7528\u306evagrant\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n

    $ vagrant plugin install vagrant-disksize vagrant-hostsupdater vagrant-mutagen vagrant-docker-compose<\/code><\/pre>\n

    vagrant\u3067\u521d\u671f\u5316\u3057\u307e\u3059\u3002<\/p>\n

    $ vagrant init ubuntu\/xenial64<\/code><\/pre>\n

    \u6b21\u306b\u3001Vagrant\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u304c\u3001Rails\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u4f5c\u6210\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3082\u3057\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306egit\u306b\u542b\u3081\u305f\u304f\u306a\u3044\u5834\u5408\u306f\u3001Vagrant\u5b9f\u884c\u7528\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3066\u3001\u305d\u3053\u306bVagrant\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n

    Vagrant\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

    Vagrant.configure('2') do |config|\n  config.vm.box = 'ubuntu\/xenial64'\n\n  config.vm.hostname = 'my-app'\n\n  config.vm.network :private_network, ip: '192.168.50.10'\n\n  config.vm.network "forwarded_port", guest: 80, host: 80\n\n  config.vm.provider :virtualbox do |vb|\n    vb.gui = false\n    vb.cpus = 4\n    vb.memory = 8192\n    vb.customize ['modifyvm', :id, '--natdnsproxy1', 'off']\n    vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'off']\n  end\n\n  config.disksize.size = '30GB'\n  config.mutagen.orchestrate = true\n\n  config.vm.synced_folder '### PATH_TO_PROJECT ###', '\/home\/vagrant\/app', type: 'rsync',\n                                                                                                              rsync_auto: true,\n                                                                                                              rsync__exclude: ['.git\/', 'node_modules\/', 'log\/', 'tmp\/', 'vendor']\n\n  config.vm.provision :docker, run: 'always'\n  config.vm.provision :docker_compose\nend<\/code><\/pre>\n

    ### PATH_TO_PROJECT ###<\/code> \u306e\u90e8\u5206\u3092\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u7d76\u5bfe\u30d1\u30b9\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n

    \u4ee5\u4e0a\u3067\u3001Vagrant+VirtualBox\u306e\u6e96\u5099\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n

    mutagen\u3067\u30d5\u30a1\u30a4\u30eb\u540c\u671f\u3059\u308b<\/h2>\n

    \u7de8\u96c6\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092Mac\u3068Linux\u3067\u540c\u671f\u3055\u305b\u307e\u3059\u3002mutagen\u3068\u3044\u3046\u30c4\u30fc\u30eb\u3067\u5b9f\u73fe\u3057\u307e\u3059\u3002<\/p>\n

    \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3001mutagen\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n

    $ brew install mutagen-io\/mutagen\/mutagen<\/code><\/pre>\n

    mutagen\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30ebmutagen.yml<\/code>\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u4f5c\u6210\u3059\u308b\u5834\u6240\u306f\u3001Vagrantfile\u3068\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

    sync:\n  app:\n    mode: "two-way-resolved"\n    alpha: "### PATH_TO_PROJECT ####"\n    beta: "my-app:\/home\/vagrant\/app"\n    ignore:\n      vcs: true\n      paths:\n        - "\/node_modules"\n        - "\/log"\n        - "\/tmp"\n        - "\/vendor"<\/code><\/pre>\n

    ### PATH_TO_PROJECT ###<\/code> \u306e\u90e8\u5206\u3092\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u7d76\u5bfe\u30d1\u30b9\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n

    \u3053\u308c\u3067\u3001mutagen\u306e\u8a2d\u5b9a\u306f\u5b8c\u4e86\u3067\u3059\u3002mutagen\u306fVagrant\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u7d4c\u7531\u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n

    Docker\u3092\u8d77\u52d5\u3059\u308b<\/h2>\n

    Vagrant\u3067\u8d77\u52d5\u3057\u305fLinux\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u307e\u3059\u3002<\/p>\n

    $ vagrant up\n$ vagrant ssh<\/code><\/pre>\n

    Unable to monitor filesystem<\/code>\u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u5834\u5408\u304c\u3042\u308b\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304a\u304d\u3001\u9632\u6b62\u3057\u307e\u3059\u3002<\/p>\n

    $ echo fs.inotify.max_user_watches=524288 | sudo tee -a \/etc\/sysctl.conf && sudo sysctl -p<\/code><\/pre>\n

    Vagrant\u306e\u4e2d\u3067\u3001Docker\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u306f\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bdocker-compose.yml\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u5834\u5408\u306e\u4f8b\u3067\u3059\u3002<\/p>\n

    $ cd app\n$ docker-compose up<\/code><\/pre>\n

    \u4ee5\u4e0a\u3067\u3001\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n

    \u4f53\u611f\u7684\u306b\u3001Docker for Mac\u3088\u308a\u3082\u9ad8\u901f\u306b\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

    \u4ed6\u306e\u6539\u5584\u65b9\u6cd5<\/h2>\n

    Docker for Mac\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6539\u5584\u306b\u95a2\u3059\u308b\u65b9\u6cd5\u306f\u3001\u4ed6\u306b\u3082\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

    Mac\u3092\u4f7f\u308f\u305a\u306bLinux PC\u3092\u4f7f\u3046<\/h3>\n

    Mac\u306b\u3053\u3060\u308f\u3089\u306a\u3051\u308c\u3070\u3001LinuxPC\u3092\u4f7f\u3046\u3053\u3068\u3082\u9078\u629e\u80a2\u306e\u4e00\u3064\u3067\u3059\u3002\u79fb\u884c\u30b3\u30b9\u30c8\u304c\u6c17\u306b\u306a\u3089\u306a\u3051\u308c\u3070\u3001\u3053\u306e\u65b9\u6cd5\u3092\u9078\u629e\u3067\u304d\u307e\u3059\u3002<\/p>\n

    docker-sync\u3092\u4f7f\u3046<\/h3>\n

    \u672a\u691c\u8a3c\u3067\u3059\u304c\u3001docker-sync\u3092\u4f7f\u3046\u65b9\u6cd5\u3082\u3042\u308b\u305d\u3046\u3067\u3059\u3002
    \nhttps:\/\/github.com\/EugenMayer\/docker-sync\/wiki<\/a><\/p>\n

    Docker\u3092\u4f7f\u308f\u306a\u3044<\/h3>\n

    \u305d\u3082\u305d\u3082Docker\u3092\u4f7f\u308f\u306a\u3044\u9078\u629e\u80a2\u3082\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u65b9\u6cd5\u306f\u3001\u30c1\u30fc\u30e0\u306e\u30e1\u30f3\u30d0\u30fc\u9593\u3067\u74b0\u5883\u5dee\u7570\u304c\u51fa\u308b\u306e\u304c\u61f8\u5ff5\u70b9\u3067\u3059\u3002\u3057\u304b\u3057\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u958b\u767a\u3067\u3042\u308c\u3070\u3001\u307b\u3068\u3093\u3069\u554f\u984c\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n

    \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306e\u958b\u767a\u74b0\u5883\u306b Docker \u306f\u4e0d\u8981(\u5c11\u306a\u304f\u3068\u3082Mac\u3067\u306f)
    \n
    https:\/\/mizchi.hatenablog.com\/entry\/2019\/04\/07\/074634<\/a><\/p>\n

    \u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u958b\u767a\u306b\u3064\u3044\u3066\u306f\u3001DB\u306a\u3069\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u5fc5\u8981\u306a\u5834\u5408\u304c\u591a\u3044\u305f\u3081\u3001Docker\u306f\u307b\u307c\u5fc5\u9808\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

    \u304a\u308f\u308a\u306b<\/h2>\n

    Docker for Mac\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306f\u3001\u958b\u767a\u52b9\u7387\u306b\u304b\u306a\u308a\u306e\u60aa\u5f71\u97ff\u3092\u53ca\u307c\u3059\u30ec\u30d9\u30eb\u3067\u3059\u3002\u958b\u767a\u3092\u9032\u3081\u308b\u524d\u306b\u3001\u6539\u5584\u3059\u308b\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n

    \u53c2\u8003<\/h2>\n