Docker是我最近一直关注的 "颠覆性 "技术之一。它是一种伟大的开发和部署的新模式。我相信未来是在容器上。这里有一个关于在Mac OSX机器上安装它的快速介绍。
在Mac OSX中使用Docker
"由于Docker引擎使用Linux特定的内核功能,你需要使用一个轻量级的虚拟机(VM)来在OSX上运行它。你使用OS X Docker客户端来控制虚拟化的Docker引擎,以构建、运行和管理Docker容器。"-docker.com
在继续之前,安装Boot2Docker。它将安装一个虚拟机(使用VirtualBox),该虚拟机已全部设置为运行Docker守护程序。
我添加了每行的信息,希望能让事情更清楚一些。
快速启动
# assuming that Boot2Docker is installed...
# initialize boot2docker and download latest ISO
# and generate public/private key pair
boot2docker init
# start VM and docker daemon (server)
boot2docker start
# initialize shell
$(boot2docker shellinit)
# upgrade
boot2docker stop
boot2docker download
boot2docker start
# test run docker
# note that if this image is not found,
# it will force download it and create
# a small container with an executable
# that prints a brief ‘Hello from Docker’
# message
docker run hello-world
# want to download a full-blown ubuntu?
# note that it could be a ~200mb download
# after it downloads, you’ll be inside
# the bash shell. `exit` to exit
docker run -it ubuntu bash
# check docker version
docker version
# if you are getting a FATA[0000] error
# your shell might not be provisioned
$(boot2docker shellinit)
# the latest version of boot2docker
# sets up a host-only network adapter
# which provides access to the
# container’s port. try running an
# nginx image at port 80
docker run --rm -i -t -p 80:80 nginx
# get boot2docker IP
boot2docker ip
# access the image’s port 80
open $(echo ‘http://’$(boot2docker ip))