{"id":2872,"date":"2019-02-20T09:38:55","date_gmt":"2019-02-20T01:38:55","guid":{"rendered":"https:\/\/damogame.cn:15443\/wordpress\/?p=2872"},"modified":"2019-02-20T09:38:55","modified_gmt":"2019-02-20T01:38:55","slug":"vagrant-%e5%85%a5%e9%97%a8%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/2872","title":{"rendered":"Vagrant \u5165\u95e8\u6307\u5357"},"content":{"rendered":"<div class=\"article-header-box\">\n<div class=\"article-header\">\n<div class=\"article-title-box\"><\/div>\n<\/div>\n<\/div>\n<article class=\"baidu_pl\">\n<div id=\"article_content\" class=\"article_content clearfix csdn-tracking-statistics\" data-pid=\"blog\" data-mod=\"popu_307\" data-dsm=\"post\">\n<div class=\"article-copyright\">Vagrant \u7b80\u4ecb<\/div>\n<div id=\"content_views\" class=\"markdown_views\">\n<p>Vagrant \u662f\u4e00\u4e2a\u7528\u6765\u6784\u5efa\u548c\u7ba1\u7406\u865a\u62df\u673a\u73af\u5883\u7684\u5de5\u5177\u3002Vagrant \u6709\u7740\u6613\u4e8e\u4f7f\u7528\u7684\u5de5\u4f5c\u6d41\uff0c\u5e76\u4e14\u4e13\u6ce8\u4e8e\u81ea\u52a8\u5316\uff0c\u964d\u4f4e\u4e86\u5f00\u53d1\u8005\u642d\u5efa\u73af\u5883\u7684\u65f6\u95f4\uff0c\u63d0\u9ad8\u4e86\u751f\u4ea7\u529b\u3002\u89e3\u51b3\u4e86\u201c\u5728\u6211\u7684\u673a\u5668\u4e0a\u53ef\u4ee5\u5de5\u4f5c\u201d\u7684\u95ee\u9898\u3002<\/p>\n<p>Vagrant \u662f\u4e3a\u4e86\u65b9\u4fbf\u7684\u5b9e\u73b0\u865a\u62df\u5316\u73af\u5883\u800c\u8bbe\u8ba1\u7684\uff0c\u4f7f\u7528 Ruby \u5f00\u53d1\uff0c\u57fa\u4e8e\u00a0<a href=\"https:\/\/www.baidu.com\/s?wd=VirtualBox&amp;tn=24004469_oem_dg&amp;rsv_dl=gh_pl_sl_csd\" target=\"_blank\" rel=\"noopener\">VirtualBox<\/a>\u00a0\u7b49\u865a\u62df\u673a\u7ba1\u7406\u8f6f\u4ef6\u7684\u63a5\u53e3\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u53ef\u914d\u7f6e\u3001\u8f7b\u91cf\u7ea7\u7684\u4fbf\u643a\u5f0f\u865a\u62df\u5f00\u53d1\u73af\u5883\u3002\u4f7f\u7528 Vagrant \u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u5c31\u5efa\u7acb\u8d77\u6765\u4e00\u4e2a\u865a\u62df\u73af\u5883\uff0c\u800c\u4e14\u53ef\u4ee5\u6a21\u62df\u591a\u53f0\u865a\u62df\u673a\uff0c\u8fd9\u6837\u6211\u4eec\u5e73\u65f6\u8fd8\u53ef\u4ee5\u5728\u5f00\u53d1\u673a\u6a21\u62df\u5206\u5e03\u5f0f\u7cfb\u7edf\u3002<\/p>\n<p>\u56e2\u961f\u65b0\u5458\u5de5\u52a0\u5165\uff0c\u5e38\u5e38\u4f1a\u9047\u5230\u82b1\u4e00\u5929\u751a\u81f3\u66f4\u591a\u65f6\u95f4\u6765\u4ece\u5934\u642d\u5efa\u5b8c\u6574\u7684\u5f00\u53d1\u73af\u5883\uff0c\u800c\u6709\u4e86Vagrant\uff0c\u53ea\u9700\u8981\u76f4\u63a5\u5c06\u5df2\u7ecf\u6253\u5305\u597d\u7684 package\uff08\u91cc\u9762\u5305\u62ec\u5f00\u53d1\u5de5\u5177\uff0c\u4ee3\u7801\u5e93\uff0c\u914d\u7f6e\u597d\u7684\u670d\u52a1\u5668\u7b49\uff09\u62ff\u8fc7\u6765\u5c31\u53ef\u4ee5\u5de5\u4f5c\u4e86\uff0c\u8fd9\u5bf9\u4e8e\u63d0\u5347\u5de5\u4f5c\u6548\u7387\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<h3 id=\"\u4e3a\u4ec0\u4e48\u9009\u62e9-vagrant\"><a name=\"t2\"><\/a>\u4e3a\u4ec0\u4e48\u9009\u62e9 Vagrant<\/h3>\n<p>Vagrant \u63d0\u4f9b\u4e86\u4e00\u4e2a\u6613\u4e8e\u914d\u7f6e\uff0c\u53ef\u91cd\u590d\u4f7f\u7528\uff0c\u517c\u5bb9\u7684\u73af\u5883\uff0c\u901a\u8fc7\u4e00\u4e2a\u5355\u4e00\u7684\u5de5\u4f5c\u6d41\u7a0b\u6765\u63a7\u5236\uff0c\u5e2e\u52a9\u4f60\u548c\u56e2\u961f\u6700\u5927\u5316\u751f\u4ea7\u529b\u548c\u7075\u6d3b\u6027\u3002<br \/>\n\u4e3a\u4e86\u5b9e\u73b0 Vagrant \u7684\u9b54\u529b\uff0cVagrant \u7ad9\u5728\u4e86\u5de8\u4eba\u7684\u80a9\u8180\u4e0a\u3002\u865a\u62df\u673a\u7684\u914d\u7f6e\u57fa\u4e8e VirtualBox\uff0cVMware\uff0cAWS \u6216\u8005\u5176\u4ed6\u63d0\u4f9b\u5546\u3002\u7136\u540e\u4e00\u4e9b\u914d\u7f6e\u5de5\u5177\uff0c\u6bd4\u5982 shell \u811a\u672c\uff0cChef \u6216\u8005 Puppet \u53ef\u4ee5\u81ea\u52a8\u5316\u5730\u5728\u865a\u62df\u673a\u5b89\u88c5\u5e76\u914d\u7f6e\u8f6f\u4ef6\u3002<\/p>\n<h4 id=\"\u5bf9\u4e8e\u5f00\u53d1\u8005\u4eba\u5458\">\u5bf9\u4e8e\u5f00\u53d1\u8005\u4eba\u5458<\/h4>\n<p>\u5982\u679c\u4f60\u662f\u4e00\u4e2a\u5f00\u53d1\u8005\uff0cVagrant \u5c06\u5728\u4e00\u4e2a\u4e00\u6b21\u6027\u7684\u3001\u4e00\u81f4\u7684\u73af\u5883\u4e2d\u9694\u79bb\u4f9d\u8d56\u9879\u53ca\u5176\u914d\u7f6e\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u4f60\u4e60\u60ef\u4f7f\u7528\u7684\u4efb\u4f55\u5de5\u5177(\u7f16\u8f91\u5668\u3001\u6d4f\u89c8\u5668\u3001\u8c03\u8bd5\u5668\u7b49)\u3002\u4e00\u65e6\u4f60\u6216\u8005\u5176\u4ed6\u4eba\u521b\u5efa\u4e86\u4e00\u4e2a Vagrantfile\uff0c\u4f60\u53ea\u9700\u8981\u6267\u884c\u00a0<code>vagrant up<\/code>\u00a0\u6240\u6709\u7684\u4e1c\u897f\u5c31\u81ea\u52a8\u5b89\u88c5\u548c\u914d\u7f6e\u4e86\u3002\u4f60\u56e2\u961f\u4e2d\u7684\u5176\u4ed6\u6210\u5458\u4f7f\u7528\u540c\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u6765\u521b\u5efa\u5f00\u53d1\u73af\u5883\uff0c\u56e0\u6b64\u4e0d\u7ba1\u4f60\u5de5\u4f5c\u5728 Linux\uff0cMacOS X \u8fd8\u662f Windows\uff0c \u6240\u6709\u56e2\u961f\u7684\u6210\u5458\u90fd\u53ef\u4ee5\u5728\u7edf\u4e00\u7684\u73af\u5883\u73af\u5883\u4e2d\u8fd0\u884c\u4ee3\u7801\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u907f\u514d\u201c\u5728\u6211\u7684\u673a\u5668\u4e0a\u53ef\u4ee5\u5de5\u4f5c\u201d\u7684\u95ee\u9898\u3002<\/p>\n<h4 id=\"\u5bf9\u4e8e\u8fd0\u7ef4\u4eba\u5458\">\u5bf9\u4e8e\u8fd0\u7ef4\u4eba\u5458<\/h4>\n<p>\u5982\u679c\u4f60\u662f\u4e00\u4e2a\u8fd0\u7ef4\u5de5\u7a0b\u5e08\u6216\u8005 DevOps \u5de5\u7a0b\u5e08\uff0cVagrant \u7ed9\u4e88\u4f60\u4e00\u4e2a\u4e00\u6b21\u6027\u7684\u73af\u5883\u6765\u5f00\u53d1\u548c\u6d4b\u8bd5\u57fa\u7840\u67b6\u6784\u7ba1\u7406\u811a\u672c\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u672c\u5730\u865a\u62df\u673a\uff08\u6bd4\u5982 VirtualBox \u6216\u8005 VMware\uff09\u9a6c\u4e0a\u6d4b\u8bd5\u4e00\u4e9b\u4e1c\u897f\uff0c\u6bd4\u5982 shell \u811a\u672c\uff0cChef cookbooks\uff0cPuppet \u6a21\u5757\u7b49\u3002\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u7528\u540c\u6837\u7684\u914d\u7f6e\u5728\u8fdc\u7a0b\u4e91\u4e0a\uff0c\u6bd4\u5982 AWS \u6216\u8005 RackSpace\uff0c\u6765\u6d4b\u8bd5\u8fd9\u4e9b\u811a\u672c\u3002\u629b\u5f03\u4e4b\u524d\u81ea\u5b9a\u4e49\u811a\u672c\u6765\u56de\u6536 EC2 \u5b9e\u4f8b\u5427\uff0c\u505c\u6b62\u4f7f\u7528 SSH \u5728\u5404\u79cd\u673a\u5668\u4e4b\u95f4\u8df3\u6765\u8df3\u53bb\uff0c\u8bf7\u5f00\u59cb\u4f7f\u7528 Vagrant \u6765\u7ed9\u4f60\u7684\u5de5\u4f5c\u5e26\u6765\u66f4\u591a\u4fbf\u5229\u3002<\/p>\n<h3 id=\"vagrant-\u548c-terraform-\u7684\u533a\u522b\"><a name=\"t3\"><\/a>Vagrant \u548c Terraform \u7684\u533a\u522b<\/h3>\n<p>Vagrant \u548c Terraform \u90fd\u51fa\u81ea\u540c\u4e00\u4e2a\u516c\u53f8\u00a0<a href=\"https:\/\/www.hashicorp.com\/\" target=\"_blank\" rel=\"nofollow noopener\">HashiCorp<\/a>\uff0c\u8be5\u516c\u53f8\u4e3b\u8981\u505a\u4e00\u4e9b\u5f00\u6e90\u8f6f\u4ef6\uff0c\u76f8\u5173\u7684\u4ea7\u54c1\u8fd8\u6709\u00a0<a href=\"https:\/\/www.packer.io\/\" target=\"_blank\" rel=\"nofollow noopener\">Packer<\/a>\uff0c<a href=\"https:\/\/www.consul.io\/\" target=\"_blank\" rel=\"nofollow noopener\">Consul<\/a>\uff0c<a href=\"https:\/\/www.vaultproject.io\/\" target=\"_blank\" rel=\"nofollow noopener\">Vault<\/a>\uff0c<a href=\"https:\/\/www.nomadproject.io\/\" target=\"_blank\" rel=\"nofollow noopener\">Nomad<\/a>\u00a0\u7b49\u3002<\/p>\n<p>Terraform \u7684\u4e3b\u8981\u7528\u9014\u662f\u7ba1\u7406\u4e91\u63d0\u4f9b\u5546\u7684\u8fdc\u7a0b\u8d44\u6e90\uff0c\u6bd4\u5982 AWS\u3002Terraform \u53ef\u4ee5\u7ba1\u7406\u6a2a\u8de8\u591a\u4e2a\u4e91\u63d0\u4f9b\u5546\u5de8\u91cf\u7684\u57fa\u7840\u8bbe\u65bd\u3002\u800c Vagrant \u4e3b\u8981\u7528\u6765\u7ba1\u7406\u4ec5\u4f7f\u7528\u5c11\u91cf\u865a\u62df\u673a\u7684\u672c\u5730\u5f00\u53d1\u73af\u5883\u3002<\/p>\n<p>Vagrant \u7528\u4e8e\u5f00\u53d1\u73af\u5883\uff0cTerraform \u666e\u904d\u7528\u4e8e\u57fa\u7840\u8bbe\u65bd\u7ba1\u7406\u3002<\/p>\n<hr \/>\n<h3 id=\"virtualbox-\u5b89\u88c5\"><a name=\"t4\"><\/a>VirtualBox \u5b89\u88c5<\/h3>\n<p>VirtualBox \u662f Oracle \u5f00\u6e90\u7684\u865a\u62df\u5316\u7cfb\u7edf\uff0c\u548c VMware \u662f\u540c\u7c7b\u4ea7\u54c1\uff0c\u652f\u6301\u591a\u4e2a\u5e73\u53f0\uff0c\u53ef\u4ee5\u5230\u5b98\u65b9\u7f51\u7ad9\uff1a<a href=\"https:\/\/www.virtualbox.org\/wiki\/Downloads\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/www.virtualbox.org\/wiki\/Downloads<\/a>\u00a0\u4e0b\u8f7d\u9002\u5408\u4f60\u5e73\u53f0\u7684 VirtualBox \u6700\u65b0\u7248\u672c\u5e76\u5b89\u88c5\u3002<\/p>\n<p><strong>\u63d0\u793a\uff1a<\/strong>\u5bf9\u4e8e Mac \u7528\u6237\uff0c\u5982\u679c\u7cfb\u7edf\u4e3a OSX 10.13.3(mac OS High Sierra) \u6216\u8005\u66f4\u9ad8\u7248\u672c\uff0c\u5b89\u88c5\u8fc7\u7a0b\u53ef\u80fd\u4f1a\u5931\u8d25\uff0c\u62a5\u9519\u63d0\u793a<code>\u5b89\u88c5\u5931\u8d25\uff0c\u5b89\u88c5\u5668\u9047\u5230\u4e86\u4e00\u4e2a\u9519\u8bef\u5bfc\u81f4\u5b89\u88c5\u5931\u8d25...<\/code>\uff0c\u539f\u56e0\u662f\u65b0\u7248\u672c Mac \u7cfb\u7edf\u7684\u5b89\u5168\u673a\u5236\u963b\u6b62\u5916\u90e8\u5185\u6838\u6269\u5c55\u5b89\u88c5\uff0c\u5bfc\u81f4\u5b89\u88c5\u5931\u8d25\u3002\u4e24\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a<br \/>\n1. \u8fdb\u5165\u7cfb\u7edf\u504f\u597d\u8bbe\u7f6e&gt;\u5b89\u5168\u6027\u4e0e\u9690\u79c1&gt;\u901a\u7528\uff0c\u7136\u540e\u624b\u52a8\u5141\u8bb8\uff1b<br \/>\n2. \u5728\u7ec8\u7aef\u6572\u547d\u4ee4\u7981\u7528\u6b64\u5b89\u5168\u7279\u6027\uff1a<code>sudo spctl --master-disable<\/code>\uff1b<\/p>\n<h3 id=\"vagrant-\u5b89\u88c5\"><a name=\"t5\"><\/a>Vagrant \u5b89\u88c5<\/h3>\n<p>\u5230\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u76f8\u5e94\u7cfb\u7edf\u5e73\u53f0\u7684\u5b89\u88c5\u5305\uff1a<a href=\"http:\/\/www.vagrantup.com\/downloads.html\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/www.vagrantup.com\/downloads.html<\/a><br \/>\n\u76f4\u63a5\u6839\u636e\u5411\u5bfc\u8fdb\u884c\u64cd\u4f5c\u5373\u53ef\u5b8c\u6210\u5b89\u88c5\uff0c\u5b89\u88c5\u5b8c\u540e\u5c31\u53ef\u4ee5\u5728\u7ec8\u7aef\u8f93\u5165\u00a0<code>vagrant<\/code>\u00a0\u547d\u4ee4\u4e86\u3002<\/p>\n<p><strong>\u63d0\u793a\uff1a<\/strong>\u5c3d\u91cf\u4e0b\u8f7d\u6700\u65b0\u7684\u7a0b\u5e8f\uff0c\u56e0\u4e3aVirtualBox\u7ecf\u5e38\u5347\u7ea7\uff0c\u5347\u7ea7\u540e\u6709\u4e9b\u63a5\u53e3\u4f1a\u53d8\u5316\uff0c\u8001\u7684Vagrant \u53ef\u80fd\u65e0\u6cd5\u4f7f\u7528\u3002<\/p>\n<h3 id=\"vagrant-\u542f\u52a8\u7b2c\u4e00\u53f0\u865a\u62df\u673a\"><a name=\"t6\"><\/a>Vagrant \u542f\u52a8\u7b2c\u4e00\u53f0\u865a\u62df\u673a<\/h3>\n<p>\u5230\u6b64\u51c6\u5907\u5de5\u4f5c\uff08VirtualBox \u548c Vagrant \u5b89\u88c5\uff09\u57fa\u672c\u4e0a\u505a\u5b8c\u4e86\uff0c\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u901a\u8fc7 Vagrant \u6765\u542f\u52a8\u4e00\u53f0\u865a\u62df\u673a\u4e86\u3002<\/p>\n<p>\u5728\u542f\u52a8\u865a\u62df\u673a\u4e4b\u524d\u5148\u7b80\u5355\u4ecb\u7ecd\u4e0b\u00a0<code>Vagrant box<\/code>\uff1a<code>box<\/code>\u00a0\u662f\u4e00\u4e2a\u6253\u5305\u597d\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u662f\u4e00\u4e2a\u540e\u7f00\u540d\u4e3a\u00a0<code>.box<\/code>\u00a0\u7684\u6587\u4ef6\uff0c\u5176\u5b9e\u662f\u4e00\u4e2a\u538b\u7f29\u5305\uff0c\u91cc\u9762\u5305\u542b\u4e86 Vagrant \u7684\u914d\u7f6e\u4fe1\u606f\u548c VirtualBox \u7684\u865a\u62df\u673a\u955c\u50cf\u6587\u4ef6\u3002<code>vagrant up<\/code>\u00a0\u542f\u52a8\u865a\u62df\u673a\u662f\u57fa\u4e8e\u00a0<code>box<\/code>\u00a0\u6587\u4ef6\u7684\uff0c\u56e0\u6b64\u5728\u542f\u52a8\u865a\u62df\u673a\u524d\u5fc5\u987b\u5f97\u628a\u00a0<code>box<\/code>\u00a0\u6587\u4ef6\u51c6\u5907\u597d\u3002\u6216\u8005\u4e5f\u53ef\u4ee5\u5728\u542f\u52a8\u7684\u65f6\u5019\u6307\u5b9a\u8fdc\u7a0b\u00a0<code>box<\/code>\u00a0\u5730\u5740\uff0c\u5728\u8fd9\u91cc\u6211\u628a\u00a0<code>box<\/code>\u00a0\u6587\u4ef6\u4e0b\u8f7d\u4e0b\u6765\uff0c\u7136\u540e\u542f\u52a8\u65f6\u6307\u5b9a\u8be5\u6587\u4ef6\u3002<\/p>\n<p>\u6211\u4f7f\u7528\u7f51\u4e0a\u5206\u4eab\u7684\u00a0<code>ubuntu-server-16.04<\/code>\u00a0\u8fd9\u4e2a\u00a0<code>box<\/code>\uff0c\u7531\u4e8e<a href=\"http:\/\/www.vagrantbox.es\/\" target=\"_blank\" rel=\"nofollow noopener\">vagrant \u5b98\u65b9 box<\/a>\u00a0\u4e0b\u8f7d\u901f\u5ea6\u7279\u522b\u6162\uff0c\u6240\u4ee5\u5728\u6b64\u63d0\u4f9b\u4e00\u4e0b\u8be5\u00a0<code>box<\/code>\u00a0\u7684<a href=\"https:\/\/www.baidu.com\/s?wd=%E7%99%BE%E5%BA%A6%E7%BD%91%E7%9B%98&amp;tn=24004469_oem_dg&amp;rsv_dl=gh_pl_sl_csd\" target=\"_blank\" rel=\"noopener\">\u767e\u5ea6\u7f51\u76d8<\/a>\u4e0b\u8f7d\u5730\u5740\uff0c\u52a0\u901f\u4e0b\u8f7d\uff1a<a href=\"https:\/\/pan.baidu.com\/s\/1wJCeWEyxKQLVPi1IH1IlYg\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/pan.baidu.com\/s\/1wJCeWEyxKQLVPi1IH1IlYg<\/a><br \/>\n1.\u65b0\u5efa\u4e00\u4e2a\u76ee\u5f55\u4f5c\u4e3a\u00a0<code>Vagrant<\/code>\u00a0\u7684\u5de5\u7a0b\u76ee\u5f55<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$haohao cd \/Users\/haohao\r\n$haohao mkdir vagrant<\/pre>\n<p>2.\u6dfb\u52a0\u524d\u9762\u4e0b\u8f7d\u7684\u00a0<code>box<\/code><br \/>\n\u6dfb\u52a0\u00a0<code>box<\/code>\u00a0\u547d\u4ee4\u683c\u5f0f\uff1a<code>vagrant box add &lt;\u672c\u5730 box \u540d\u79f0&gt; &lt;box \u6587\u4ef6&gt;<\/code><\/p>\n<ul>\n<li>\u672c\u5730\u00a0<code>box<\/code>\u00a0\u540d\u79f0\uff1a\u81ea\u5b9a\u4e49\u540d\u79f0\uff0c\u8be5\u540d\u79f0\u662f\u672c\u5730\u00a0<code>vagrant<\/code>\u00a0\u7ba1\u7406\u65f6\u4f7f\u7528\u7684\u540d\u79f0\uff1b<\/li>\n<li><code>box<\/code>\u00a0\u6587\u4ef6\uff1a\u524d\u9762\u4e0b\u8f7d\u7684\u00a0<code>vagrant box<\/code>\u00a0\u6587\u4ef6\u6216\u8005\u8fdc\u7a0b\u00a0<code>box<\/code>\u00a0url \u5730\u5740\uff1b<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$haohao vagrant box add ubuntu-server-16.04 ubuntu-server-16.04-amd64-vagrant.box\r\n==&gt; box: Box file was not detected as metadata. Adding it directly...\r\n==&gt; box: Adding box 'ubuntu-server-16.04' (v0) for provider:\r\n    box: Unpacking necessary files from: file:\/\/\/Users\/haohao\/vagrant\/ubuntu-server-16.04-amd64-vagrant.box\r\n==&gt; box: Successfully added box 'ubuntu-server-16.04' (v0) for 'virtualbox'!<\/pre>\n<p>3.\u67e5\u770b\u00a0<code>box<\/code>\u00a0\u662f\u5426\u6dfb\u52a0\u6210\u529f<br \/>\n\u67e5\u770b\u5f53\u524d\u00a0<code>vagrant<\/code>\u00a0\u4e2d\u6709\u54ea\u4e9b\u00a0<code>box<\/code>\uff1a<code>vagrant box list<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$haohao vagrant box list\r\nubuntu-server-16.04 (virtualbox, 0)<\/pre>\n<p>4.\u521d\u59cb\u5316\u4e0a\u9762\u6dfb\u52a0\u7684\u00a0<code>box<\/code><br \/>\n\u521d\u59cb\u5316\u547d\u4ee4\u683c\u5f0f\uff1a<code>vagrant init &lt;\u672c\u5730 box \u540d\u79f0&gt;<\/code><br \/>\n\u672c\u5730\u00a0<code>box<\/code>\u00a0\u540d\u79f0\uff1a\u7b2c 2 \u6b65\u4e2d\u6dfb\u52a0\u7684\u00a0<code>box<\/code>\u00a0\u540d\u79f0<br \/>\n\u8fd9\u91cc\u521d\u59cb\u5316\u524d\u9762\u6dfb\u52a0\u7684\u00a0<code>box<\/code>\uff0c\u521d\u59cb\u5316\u540e\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u751f\u4ea7\u4e00\u4e2a\u00a0<code>Vagrantfile<\/code>\u00a0\u6587\u4ef6\uff0c\u91cc\u9762\u5305\u542b\u4e86\u865a\u62df\u673a\u7684\u5404\u79cd\u914d\u7f6e\uff0c\u5173\u4e8e\u5177\u4f53\u6bcf\u4e2a\u914d\u7f6e\u9879\u662f\u4ec0\u4e48\u610f\u601d\uff0c\u540e\u9762\u4f1a\u4ecb\u7ecd\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$haohao vagrant init 'ubuntu-server-16.04'\r\nA `Vagrantfile` has been placed in this directory. You are now\r\nready to `vagrant up` your first virtual environment! Please read\r\nthe comments in the Vagrantfile as well as documentation on\r\n`vagrantup.com` for more information on using Vagrant.<\/pre>\n<p>5.\u542f\u52a8\u865a\u62df\u673a<br \/>\n\u865a\u62df\u673a\u542f\u52a8\u547d\u4ee4\uff1a<code>vagrant up<\/code><br \/>\n\u542f\u52a8\u865a\u62df\u673a\u65f6\u4f1a\u81ea\u52a8\u5c06\u5f53\u524d\u76ee\u5f55\uff08\u5373 Vagrantfile \u6587\u4ef6\u6240\u5728\u76ee\u5f55\uff09\uff0c\u548c\u865a\u62df\u673a\u7684\u00a0<code>\/vagrant<\/code>\u00a0\u76ee\u5f55\u5171\u4eab\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$haohao vagrant up\r\nBringing machine 'default' up with 'virtualbox' provider...\r\n==&gt; default: Importing base box 'ubuntu-server-16.04'...\r\n==&gt; default: Matching MAC address for NAT networking...\r\n==&gt; default: Setting the name of the VM: vagrant_default_1524288099752_62326\r\n==&gt; default: Clearing any previously set network interfaces...\r\n.....\r\n==&gt; default: Mounting shared folders...\r\n    default: \/vagrant =&gt; \/Users\/haohao\/vagrant<\/pre>\n<p>&nbsp;<\/p>\n<p>6.\u8fde\u63a5\u865a\u62df\u673a<br \/>\n\u547d\u4ee4\u683c\u5f0f\uff1a<code>vagrant ssh<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$haohao vagrant ssh\r\nWelcome to Ubuntu 16.04.3 LTS (GNU\/Linux 4.4.0-98-generic x86_64)\r\n\r\n * Documentation:  https:\/\/help.ubuntu.com\r\n * Management:     https:\/\/landscape.canonical.com\r\n * Support:        https:\/\/ubuntu.com\/advantage\r\n\r\n  Get cloud support with Ubuntu Advantage Cloud Guest:\r\n    http:\/\/www.ubuntu.com\/business\/services\/cloud\r\n\r\n0 packages can be updated.\r\n0 updates are security updates.\r\n\r\nLast login: Sat Apr 21 05:28:37 2018 from 10.0.2.2\r\nubuntu@ubuntu-xenial:~$<\/pre>\n<p>7.\u67e5\u770b Vagrant \u5171\u4eab\u76ee\u5f55<br \/>\n\u8fdb\u5165\u865a\u62df\u673a\u540e\u6267\u884c\u00a0<code>df -h<\/code>\u00a0\u53ef\u4ee5\u770b\u5230 Vagrant \u9ed8\u8ba4\u628a\u5bbf\u4e3b\u673a\u00a0<code>Vagrantfile<\/code>\u00a0\u6240\u5728\u7684\u76ee\u5f55\u548c\u865a\u62df\u673a\u7684\u00a0<code>\/vagrant<\/code>\u00a0\u76ee\u5f55\u5171\u4eab\uff0c\u53ef\u4ee5\u901a\u8fc7\u00a0<code>ls \/vagrant\/<\/code>\u00a0\u67e5\u770b\u8be5\u76ee\u5f55\u5185\u5bb9\uff0c\u5185\u5bb9\u548c\u5bbf\u4e3b\u673a\u5bf9\u5e94\u76ee\u5f55\u4e00\u81f4\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">ubuntu@ubuntu-xenial:~$ df -h\r\nFilesystem      Size  Used Avail Use% Mounted on\r\nudev            490M     0  490M   0% \/dev\r\ntmpfs           100M  3.1M   97M   4% \/run\r\n\/dev\/sda1       9.7G  857M  8.8G   9% \/\r\ntmpfs           497M     0  497M   0% \/dev\/shm\r\ntmpfs           5.0M     0  5.0M   0% \/run\/lock\r\ntmpfs           497M     0  497M   0% \/sys\/fs\/cgroup\r\nvagrant         234G   49G  185G  21% \/vagrant\r\ntmpfs           100M     0  100M   0% \/run\/user\/1000\r\n\r\n# ls \u67e5\u770b\u8be5\u5171\u4eab\u76ee\u5f55\u5185\u5bb9\u548c\u5bbf\u4e3b\u673a\u5185\u5bb9\u4e00\u81f4\r\nubuntu@ubuntu-xenial:~$ ls \/vagrant\/\r\nubuntu-xenial-16.04-cloudimg-console.log  Vagrantfile<\/pre>\n<h3 id=\"vagrant-\u914d\u7f6e\u6587\u4ef6\u6d45\u6790\"><a name=\"t7\"><\/a>Vagrant \u914d\u7f6e\u6587\u4ef6\u6d45\u6790<\/h3>\n<p>\u524d\u9762\u6211\u4eec\u6267\u884c\u00a0<code>vagrant init &lt;\u672c\u5730 box \u540d\u79f0&gt;<\/code>\u00a0\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u751f\u6210\u00a0<code>Vagrantfile<\/code>\u00a0\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u4e00\u822c\u7ed9\u522b\u4eba\u5171\u4eab\u81ea\u5df1\u7684\u73af\u5883\u65f6\u90fd\u662f\u63d0\u4f9b\u4e00\u4e2a\u00a0<code>Vagrantfile<\/code>\u00a0\u548c\u4e00\u4e2a\u00a0<code>box<\/code>\u00a0\u6587\u4ef6\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5f88\u8f7b\u677e\u5730\u5c06\u73af\u5883\u5171\u4eab\u7ed9\u522b\u4eba\uff0c\u522b\u4eba\u80fd\u5f97\u5230<a href=\"https:\/\/www.baidu.com\/s?wd=%E4%B8%80%E6%A8%A1%E4%B8%80%E6%A0%B7&amp;tn=24004469_oem_dg&amp;rsv_dl=gh_pl_sl_csd\" target=\"_blank\" rel=\"noopener\">\u4e00\u6a21\u4e00\u6837<\/a>\u7684\u7edf\u4e00\u7684\u73af\u5883\uff0c\u8fd9\u5c31\u662f\u4f7f\u7528\u00a0<code>Vagrant<\/code>\u00a0\u7684\u597d\u5904\u3002<\/p>\n<p><code>Vagrantfile<\/code>\u00a0\u4e3b\u8981\u5305\u62ec\u4e09\u4e2a\u65b9\u9762\u7684\u914d\u7f6e\uff0c\u865a\u62df\u673a\u7684\u914d\u7f6e\u3001SSH\u914d\u7f6e\u3001Vagrant \u7684\u4e00\u4e9b\u57fa\u7840\u914d\u7f6e\u3002Vagrant \u662f\u4f7f\u7528 Ruby \u5f00\u53d1\u7684\uff0c\u6240\u4ee5\u5b83\u7684\u914d\u7f6e\u8bed\u6cd5\u4e5f\u662f Ruby \u7684\uff0c\u5bf9\u4e8e\u6ca1\u6709\u5b66\u8fc7 Ruby \u7684\u670b\u53cb\u4e5f\u6ca1\u5173\u7cfb\uff0c\u6839\u636e\u4f8b\u5b50\u6a21\u4eff\u4e0b\u5c31\u4f1a\u4e86\u3002<\/p>\n<p>\u4fee\u6539\u5b8c\u914d\u7f6e\u540e\u9700\u8981\u6267\u884c\u00a0<code>vagrant reload<\/code>\u00a0\u91cd\u542f VM \u4f7f\u5176\u914d\u7f6e\u751f\u6548\u3002<\/p>\n<p>\u4ee5\u4e0b\u7b80\u5355\u4ecb\u7ecd\u4e0b\u5e38\u7528\u914d\u7f6e\u7684\u914d\u7f6e\u9879\uff1a<br \/>\n1.\u00a0<code>box<\/code>\u00a0\u540d\u79f0\u8bbe\u7f6e<br \/>\n<code>config.vm.box = \"base\"<\/code><br \/>\n\u4e0a\u9762\u8fd9\u914d\u7f6e\u5c55\u793a\u4e86 Vagrant \u8981\u53bb\u542f\u7528\u90a3\u4e2abox\u4f5c\u4e3a\u7cfb\u7edf\uff0c\u4e5f\u5c31\u662f\u524d\u9762\u6211\u4eec\u8f93\u5165\u00a0<code>vagrant init &lt;\u672c\u5730 box \u540d\u79f0&gt;<\/code>\u65f6\u6240\u6307\u5b9a\u7684\u00a0<code>box<\/code>\uff0c\u5982\u679c\u6c92\u6709\u8f93\u5165\u00a0<code>box<\/code>\u00a0\u540d\u79f0\u7684\u8bdd\uff0c\u90a3\u4e48\u9ed8\u8ba4\u5c31\u662f\u00a0<code>base<\/code>\u3002<\/p>\n<p>2.VM \u76f8\u5173\u914d\u7f6e<br \/>\nVirtualBox \u63d0\u4f9b\u4e86 VBoxManage \u8fd9\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u8bbe\u5b9a VM\uff0c\u7528<code>modifyvm<\/code>\u8fd9\u4e2a\u547d\u4ee4\u8ba9\u6211\u4eec\u53ef\u4ee5\u8bbe\u5b9a VM \u7684\u540d\u79f0\u548c\u5185\u5b58\u5927\u5c0f\u7b49\u7b49\uff0c\u8fd9\u91cc\u8bf4\u7684\u540d\u79f0\u6307\u7684\u662f\u5728 VirtualBox \u4e2d\u663e\u793a\u7684\u540d\u79f0\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728 Vagrantfile \u4e2d\u8fdb\u884c\u8bbe\u5b9a\uff0c\u4e3e\u4f8b\u5982\u4e0b\uff1a<\/p>\n<p>\u8c03\u7528 VBoxManage \u7684\u00a0<code>modifyvm<\/code>\u00a0\u7684\u547d\u4ee4\uff0c\u8bbe\u7f6e VM \u7684\u540d\u79f0\u4e3a\u00a0<code>ubuntu<\/code>\uff0c\u5185\u5b58\u4e3a 1024 MB\u3002\u4f60\u53ef\u4ee5\u7c7b\u4f3c\u7684\u901a\u8fc7\u5b9a\u5236\u5176\u5b83 VM \u5c5e\u6027\u6765\u5b9a\u5236\u4f60\u81ea\u5df1\u7684 VM\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">config.vm.provider \"virtualbox\" do |v|\r\n  v.customize [\"modifyvm\", :id, \"--name\", \"ubuntu\", \"--memory\", \"1024\"]\r\nend<\/pre>\n<p>3.\u7f51\u7edc\u8bbe\u7f6e<br \/>\nVagrant \u6709\u4e24\u79cd\u65b9\u5f0f\u6765\u8fdb\u884c\u7f51\u7edc\u8fde\u63a5\uff0c\u4e00\u79cd\u662f host-only (\u4e3b\u673a\u6a21\u5f0f)\uff0c\u8fd9\u79cd\u6a21\u5f0f\u4e0b\u6240\u6709\u7684\u865a\u62df\u7cfb\u7edf\u662f\u53ef\u4ee5\u4e92\u76f8\u901a\u4fe1\u7684\uff0c\u4f46\u865a\u62df\u7cfb\u7edf\u548c\u771f\u5b9e\u7684\u7f51\u7edc\u662f\u88ab\u9694\u79bb\u5f00\u7684\uff0c\u865a\u62df\u673a\u548c\u5bbf\u4e3b\u673a\u662f\u53ef\u4ee5\u4e92\u76f8\u901a\u4fe1\u7684\uff0c\u76f8\u5f53\u4e8e\u4e24\u53f0\u673a\u5668\u901a\u8fc7\u53cc\u7ede\u7ebf\u4e92\u8054\u3002\u53e6\u4e00\u79cd\u662fBridge(\u6865\u63a5\u6a21\u5f0f)\uff0c\u8be5\u6a21\u5f0f\u4e0b\u7684 VM \u5c31\u50cf\u662f\u5c40\u57df\u7f51\u4e2d\u7684\u4e00\u53f0\u72ec\u7acb\u7684\u4e3b\u673a\uff0c\u53ef\u4ee5\u548c\u5c40\u57df\u7f51\u4e2d\u7684\u4efb\u4f55\u4e00\u53f0\u673a\u5668\u901a\u4fe1\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u9700\u8981\u624b\u52a8\u7ed9 VM \u914d IP \u5730\u5740\uff0c\u5b50\u7f51\u63a9\u7801\u7b49\u3002\u6211\u4eec\u4e00\u822c\u9009\u62e9 host-only \u6a21\u5f0f\uff0c\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">config.vm.network :private_network, ip: \"11.11.11.11\"<\/pre>\n<p>4.hostname \u8bbe\u7f6e<br \/>\n<code>hostname<\/code>\u00a0\u7684\u8bbe\u7f6e\u975e\u5e38\u7b80\u5355\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">config.vm.hostname = \"kubernetes\"<\/pre>\n<p>5.\u76ee\u5f55\u5171\u4eab<br \/>\n\u6211\u4eec\u524d\u9762\u4ecb\u7ecd\u8fc7<code>\/vagrant<\/code>\u76ee\u5f55\u9ed8\u8ba4\u5c31\u662f\u5f53\u524d\u7684\u5f00\u53d1\u76ee\u5f55\uff0c\u8fd9\u662f\u5728\u865a\u62df\u673a\u5f00\u542f\u7684\u65f6\u5019\u9ed8\u8ba4\u6302\u8f7d\u540c\u6b65\u7684\u3002\u6211\u4eec\u8fd8\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u6765\u8bbe\u7f6e\u989d\u5916\u7684\u540c\u6b65\u76ee\u5f55\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># \u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u4e3b\u673a\u7684\u76ee\u5f55\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u865a\u62df\u673a\u6302\u8f7d\u7684\u76ee\u5f55\r\nconfig.vm.synced_folder  \"\/Users\/haohao\/data\", \"\/vagrant_data\"<\/pre>\n<p>6.\u7aef\u53e3\u8f6c\u53d1<br \/>\n\u5bf9\u5bbf\u4e3b\u673a\u5668\u4e0a 8080 \u7aef\u53e3\u7684\u8bbf\u95ee\u8bf7\u6c42 forward \u5230\u865a\u62df\u673a\u7684 80 \u7aef\u53e3\u7684\u670d\u52a1\u4e0a\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">config.vm.network :forwarded_port, guest: 80, host: 8080<\/pre>\n<h3 id=\"vagrant-\u5e38\u7528\u547d\u4ee4\u6e05\u5355\"><a name=\"t8\"><\/a>Vagrant \u5e38\u7528\u547d\u4ee4\u6e05\u5355<\/h3>\n<ul>\n<li><code>vagrant box add<\/code>\u00a0\u6dfb\u52a0box<\/li>\n<li><code>vagrant init<\/code>\u00a0\u521d\u59cb\u5316 box<\/li>\n<li><code>vagrant up<\/code>\u00a0\u542f\u52a8\u865a\u62df\u673a<\/li>\n<li><code>vagrant ssh<\/code>\u00a0\u767b\u5f55\u865a\u62df\u673a<\/li>\n<li><code>vagrant box list<\/code>\u00a0\u5217\u51fa Vagrant \u5f53\u524d\u00a0<code>box<\/code>\u00a0\u5217\u8868<\/li>\n<li><code>vagrant box remove<\/code>\u00a0\u5220\u9664\u76f8\u5e94\u7684\u00a0<code>box<\/code><\/li>\n<li><code>vagrant destroy<\/code>\u00a0\u505c\u6b62\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u865a\u62df\u673a\u5e76\u9500\u6bc1\u6240\u6709\u521b\u5efa\u7684\u8d44\u6e90<\/li>\n<li><code>vagrant halt<\/code>\u00a0\u5173\u673a<\/li>\n<li><code>vagrant package<\/code>\u00a0\u628a\u5f53\u524d\u7684\u8fd0\u884c\u7684\u865a\u62df\u673a\u73af\u5883\u8fdb\u884c\u6253\u5305\u4e3a\u00a0<code>box<\/code>\u00a0\u6587\u4ef6<\/li>\n<li><code>vagrant plugin<\/code>\u00a0\u5b89\u88c5\u5378\u8f7d\u63d2\u4ef6<\/li>\n<li><code>vagrant reload<\/code>\u00a0\u91cd\u65b0\u542f\u52a8\u865a\u62df\u673a\uff0c\u91cd\u65b0\u8f7d\u5165\u914d\u7f6e\u6587\u4ef6<\/li>\n<li><code>vagrant resume<\/code>\u00a0\u6062\u590d\u88ab\u6302\u8d77\u7684\u72b6\u6001<\/li>\n<li><code>vagrant status<\/code>\u00a0\u83b7\u53d6\u5f53\u524d\u865a\u62df\u673a\u7684\u72b6\u6001<\/li>\n<li><code>vagrant suspend<\/code>\u00a0\u6302\u8d77\u5f53\u524d\u7684\u865a\u62df\u673a<\/li>\n<li><code>vagrant global-status<\/code>\u00a0\u67e5\u770b\u5f53\u524d vagrant \u7ba1\u7406\u7684\u6240\u6709 vm \u4fe1\u606f<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$ vagrant global-status                                                                                                                                \r\nid       name    provider   state   directory\r\n------------------------------------------------------------------------\r\naeb2f19  default virtualbox running \/Users\/haohao\/vagrant\r\n2cd1f42  default virtualbox aborted \/Users\/haohao\/vagrant-test\r\n943c1bf  default virtualbox aborted \/Users\/haohao\/work\/vm<\/pre>\n<ul>\n<li><code>vagrant ssh-config<\/code>\u00a0\u8f93\u51fa\u7528\u4e8e ssh \u8fde\u63a5\u7684\u4e00\u4e9b\u4fe1\u606f<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">$ vagrant ssh-config                                                                                                                                   \r\nHost default\r\n  HostName 127.0.0.1\r\n  User ubuntu\r\n  Port 2222\r\n  UserKnownHostsFile \/dev\/null\r\n  StrictHostKeyChecking no\r\n  PasswordAuthentication no\r\n  IdentityFile \/Users\/haohao\/vagrant\/.vagrant\/machines\/default\/virtualbox\/private_key\r\n  IdentitiesOnly yes\r\n  LogLevel FATAL<\/pre>\n<h3 id=\"vagrant-\u542f\u52a8\u865a\u62df\u673a\u96c6\u7fa4\"><a name=\"t9\"><\/a>Vagrant \u542f\u52a8\u865a\u62df\u673a\u96c6\u7fa4<\/h3>\n<p>\u524d\u9762\u6211\u4eec\u90fd\u662f\u901a\u8fc7\u4e00\u4e2a\u00a0<code>Vagrantfile<\/code>\u00a0\u914d\u7f6e\u542f\u52a8\u5355\u53f0\u673a\u5668\uff0c\u5982\u679c\u6211\u4eec\u8981\u542f\u52a8\u4e00\u4e2a\u96c6\u7fa4\uff0c\u90a3\u4e48\u53ef\u4ee5\u628a\u9700\u8981\u7684\u8282\u70b9\u5728\u4e00\u4e2a\u00a0<code>Vagrantfile<\/code>\u00a0\u5199\u597d\uff0c\u7136\u540e\u76f4\u63a5\u5c31\u53ef\u4ee5\u901a\u8fc7\u00a0<code>vagrant up<\/code>\u00a0\u540c\u65f6\u542f\u52a8\u591a\u4e2a VM \u7ec4\u6210\u4e00\u4e2a\u96c6\u7fa4\u3002\u4ee5\u4e0b\u793a\u4f8b\u914d\u7f6e\u4e00\u4e2a web \u8282\u70b9\u548c\u4e00\u4e2a db \u8282\u70b9\uff0c\u4e24\u4e2a\u8282\u70b9\u5728\u540c\u4e00\u4e2a\u7f51\u6bb5\uff0c\u5e76\u4e14\u4f7f\u7528\u540c\u4e00\u4e2a\u00a0<code>box<\/code>\u00a0\u542f\u52a8\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Vagrant.configure(\"2\") do |config|\r\n  config.vm.define :web do |web|\r\n    web.vm.provider \"virtualbox\" do |v|\r\n          v.customize [\"modifyvm\", :id, \"--name\", \"web\", \"--memory\", \"512\"]\r\n    end\r\n    web.vm.box = \"ubuntu-server-16.04\"\r\n    web.vm.hostname = \"web\"\r\n    web.vm.network :private_network, ip: \"11.11.1.1\"\r\n  end\r\n\r\n  config.vm.define :db do |db|\r\n    db.vm.provider \"virtualbox\" do |v|\r\n          v.customize [\"modifyvm\", :id, \"--name\", \"db\", \"--memory\", \"512\"]\r\n    end\r\n    db.vm.box = \"ubuntu-server-16.04\"\r\n    db.vm.hostname = \"db\"\r\n    db.vm.network :private_network, ip: \"11.11.1.2\"\r\n  end\r\nend<\/pre>\n<h3 id=\"\u76f8\u5173\u8fde\u63a5\"><a name=\"t10\"><\/a>\u76f8\u5173\u8fde\u63a5<\/h3>\n<p><a href=\"https:\/\/www.vagrantup.com\/intro\/index.html\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/www.vagrantup.com\/intro\/index.html<\/a><br \/>\n<a href=\"https:\/\/blog.csdn.net\/rickiyeat\/article\/details\/55097687\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/blog.csdn.net\/rickiyeat\/article\/details\/55097687<\/a><br \/>\n<a href=\"https:\/\/github.com\/astaxie\/go-best-practice\/blob\/master\/ebook\/zh\/01.0.md\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/github.com\/astaxie\/go-best-practice\/blob\/master\/ebook\/zh\/01.0.md<\/a><\/p>\n<\/div>\n<\/div>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>Vagrant \u7b80\u4ecb Vagrant \u662f<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[122],"class_list":["post-2872","post","type-post","status-publish","format-standard","hentry","tag-06-godocker"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=2872"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2872\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=2872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=2872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=2872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}