您的位置:首页 > 运维架构 > Docker

新手玩Docker

2015-06-16 00:21 633 查看
参考资料chenhengjie123 ,感谢@chenhengjie123分享

环境

实验所用的是os x系统,所以需要通过boot2docker来引导,然后需要VirtualBox VM启动docker,所以可想而知我们的环境需要3个组件:

docker

boot2docker

VirtualBox

docker和boot2docker可以通过命令行安装,也可以通过安装包安装,但是别忘了VirtualBox VM的安装哦,安装后就是小面的小图标:



启动Docker

boot2docker init
创建Docker虚拟机

我们打开VirtualBox:



左边栏是空的,好了,现在我们使用boot2docker来创建docker客户端所需的虚拟机,看动画:



启动完成后就是这么一个鬼



我们动画中演示的是从VirturalBox中双击启动Docker 客户端,也可以在外部通过
boot2docker start
启动.这样启动后,完全是看不到VirturalBox里的内容也看不到海豚的图像.

Hello World

要想在外部连接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:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(Assuming it was not already locally available.)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

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/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: