参考资料chenhengjie123 ,感谢@chenhengjie123分享
实验所用的是 os x 系统,所以需要通过 boot2docker 来引导,然后需要 VirtualBox VM 启动 docker,所以可想而知我们的环境需要 3 个组件:
docker 和 boot2docker 可以通过命令行安装,也可以通过安装包安装,但是别忘了 VirtualBox VM 的安装哦,安装后就是小面的小图标:
boot2docker init
创建 Docker 虚拟机
我们打开 VirtualBox:
左边栏是空的,好了,现在我们使用 boot2docker 来创建 docker 客户端所需的虚拟机,看动画:
启动完成后就是这么一个鬼
我们动画中演示的是从 VirturalBox 中双击启动 Docker 客户端,也可以在外部通过boot2docker start
启动.这样启动后,完全是看不到 VirturalBox 里的内容也看不到海豚的图像.
要想在外部连接 Docker 客户端,需要先设置环境变量,通过下面命令执行:
eval '$(boot2docker shellinit)'
跑个官方提供的 hello-world 镜像:
docker run <镜像名>
localhost:~ wuxian$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from hello-world
a8219747be10: Pull complete
91c95931e552: Already exists
hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd18681cf5daeb82aab55838d
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
For more examples and ideas, visit:
http://docs.docker.com/userguide/