{"action":"opened","issue":{"url":"https://api.github.com/repos/imsobear/tec_blog/issues/55","labels_url":"https://api.github.com/repos/imsobear/tec_blog/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/imsobear/tec_blog/issues/55/comments","events_url":"https://api.github.com/repos/imsobear/tec_blog/issues/55/events","html_url":"https://github.com/imsobear/tec_blog/issues/55","id":54657936,"number":55,"title":"Docker-1: 在 Mac OSX 上安装 boot2docker","user":{"login":"imsobear","id":2505411,"avatar_url":"https://avatars.githubusercontent.com/u/2505411?v=3","gravatar_id":"","url":"https://api.github.com/users/imsobear","html_url":"https://github.com/imsobear","followers_url":"https://api.github.com/users/imsobear/followers","following_url":"https://api.github.com/users/imsobear/following{/other_user}","gists_url":"https://api.github.com/users/imsobear/gists{/gist_id}","starred_url":"https://api.github.com/users/imsobear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imsobear/subscriptions","organizations_url":"https://api.github.com/users/imsobear/orgs","repos_url":"https://api.github.com/users/imsobear/repos","events_url":"https://api.github.com/users/imsobear/events{/privacy}","received_events_url":"https://api.github.com/users/imsobear/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-17T10:32:03Z","updated_at":"2015-01-17T10:32:03Z","closed_at":null,"body":"\r\n因为 docker 引擎使用的是 Linux 内核的特性，所以想要在 OSＸ上运行 docker，我们就需要在 MAC 上提供一个虚拟机环境，那这个环境就是 [boot2docker](https://github.com/boot2docker/boot2docker) 这个工具。\r\n\r\n### 1. 安装 VirtualBox:\r\n\r\n直接去 [VirtualBox Downloads](https://www.virtualbox.org/wiki/Downloads) 下载对应的 .dmg 文件然后安装即可。\r\n\r\n这时候打开 VirtualBox 里面是没有虚拟机的。\r\n\r\n### 2. 安装 boot2docker: `brew install boot2docker`\r\n\r\n因为 docker 是运行在 Linux 下的，所以是无法直接运行于 OSX 下的，因此就需要 boot2docker(Lightweight Linux for Docker) 这个工具，具体可参考 [boot2docker in github](https://github.com/boot2docker/boot2docker)。\r\n\r\n安装方法：\r\n\r\n### 3. 启动 boot2docker:\r\n\r\n#### (1) 初始化：\r\n\r\n在正常的国度，只需要直接运行 `boot2docker init` 即可，不过，因为某些大家都知道的原因，我朝人民的做法有点不一样：\r\n\r\n下载 boot2docker 的镜像：建议直接去 [boot2docker github](https://github.com/boot2docker/boot2docker/releases) 下载，如果还是很慢，可以考虑 [V2EX 做的镜像](https://www.v2ex.com/t/152344)，不过版本稍微有点低（1.3）。\r\n\r\n然后将下载的 `boot2docker.iso` 复制到 `~/.boot2docker` 文件夹里，这时候再执行 `boot2docker init`，会生成一段对应的密钥，同时打开 VirtualBox 会看到对应的虚拟机：\r\n\r\n![](http://gtms02.alicdn.com/tps/i2/TB1fYeEHXXXXXb6XpXX.JNVFXXX-769-546.png)\r\n\r\n#### (2) 启动 boot2docker 虚拟机\r\n\r\n执行：`boot2docker up`：\r\n\r\n![](http://gtms01.alicdn.com/tps/i1/TB1cKSDHXXXXXcUXpXXrFgW9FXX-658-246.png)\r\n\r\n虚拟机对应的其他一些管理命令：\r\n\r\n```\r\nboot2docker {init|start|up|save|pause|stop|restart|status|info|delete|ssh|download}\r\n```\r\n\r\n截至这三步结束，其实我们只是完成了一件事：**在 Mac 上为 docker 提供了 linux 的运行环境-boot2docker-vm.**\r\n\r\n### 疑问：\r\n\r\n看很多文章说安装了 boot2docker 后，还需要安装 docker: `brew install docker`，在我的电脑上安装完 boot2docker 后就可以直接运行 `docker -v`，集成了？还是我之前安装过？\r\n\r\n--------------\r\n\r\n### 参考链接：\r\n\r\n- [how-to-use-docker-on-os-x-the-missing-guide](http://viget.com/extend/how-to-use-docker-on-os-x-the-missing-guide)\r\n"}}