之前在文章《 Mac OS X Yosemite 10.10.1安装Docker》中介绍了如何使用Boot2Docker在Mac上安装Docker,时隔变迁,现在Boot2Docker已经被官方废弃,取而代之的是Toolbox。
关于boot2docker的说明:
This project (the boot2docker OS X Installer) is officially deprecated in favor of the new Docker Toolbox.
关于Toolbox的说明:
The Docker Toolbox is an installer to quickly and easily install and setup a Docker environment on your computer.
Available for both Windows and Mac, the Toolbox installs Docker Client, Machine, Compose (Mac only) and Kitematic.
Note: 目前Toolbox仅支持Windows和Mac版本。
下面根据官方Toolbox的安装说明,体验新工具带来了哪些新的功能。
Mac OS X users use Docker Toolbox to install Docker software. Docker Toolbox includes the following Docker tools:
- Docker CLI client for running Docker Engine to create images and containers
- Docker Machine so you can run Docker Engine commands from Mac OS X terminals
- Docker Compose for running the docker-compose command
- Kitematic, the Docker GUI
- the Docker QuickStart shell preconfigured for a Docker command-line environment
- Oracle VM VirtualBox
Because the Docker Engine daemon uses Linux-specific kernel features, you can’t run Docker Engine natively in OS X. Instead, you must use the Docker Machine command,
docker-machine
, to create and attach to a small Linux VM on your machine. This VM hosts Docker Engine for you on your Mac.
1 前提要求
Your Mac must be running OS X 10.8 “Mountain Lion” or newer to run Docker software.
2 下载Toolbox
下载 Docker Toolbox,174MB。
By default, the standard Docker Toolbox installation:
- installs binaries for the Docker tools in
/usr/local/bin
- makes these binaries available to all users
- updates any existing Virtual Box installation
下载完成后开始安装:
PS: 在开始安装Toolbox前,需要使用命令boot2docker stop
先退出VM服务,如果事先运行了boot2docker的话。
在安装向导中可以看到,会安装哪些工具,以及这些工具安装后的路径。总共需要占用465.9MB的磁盘空间:
在安装过程中,会提示选择一个工具来启动Docker:
* Docker Quickstart Terminal
* Kitematic (Beta) - Visual Management for Docker
我们选择第一个。(这里也可以不选择,直接继续完成安装,在安装完成后再启动)
假如上面选择了第一个,然后会激活一个终端,并显示如下内容:
Creating CA: /Users/gerryyang/.docker/machine/certs/ca.pem
Creating client certificate: /Users/gerryyang/.docker/machine/certs/cert.pem
Running pre-create checks...
Creating machine...
(default) Copying /Users/gerryyang/.docker/machine/cache/boot2docker.iso to /Users/gerryyang/.docker/machine/machines/default/boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Check network to re-create if needed...
(default) Found a new host-only adapter: "vboxnet1"
(default) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: /usr/local/bin/docker-machine env default
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
上面内容总结一句话:
The terminal does a number of things to set up Docker Quickstart Terminal for you.
查看安装目录下的文件变化:
同时在应用程序中多了两个应用图标:
然后根据上面的提示完成启动Docker daemon:
gerryyang@mba:bin$docker run hello-world
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
gerryyang@mba:bin$/usr/local/bin/docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/gerryyang/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval $(/usr/local/bin/docker-machine env default)
gerryyang@mba:bin$docker version
Client:
Version: 1.10.1
API version: 1.22
Go version: go1.5.3
Git commit: 9e83765
Built: Thu Feb 11 19:14:21 2016
OS/Arch: darwin/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
gerryyang@mba:bin$eval $(/usr/local/bin/docker-machine env default)
gerryyang@mba:bin$docker version
Client:
Version: 1.10.1
API version: 1.22
Go version: go1.5.3
Git commit: 9e83765
Built: Thu Feb 11 19:14:21 2016
OS/Arch: darwin/amd64
Server:
Version: 1.10.1
API version: 1.22
Go version: go1.5.3
Git commit: 9e83765
Built: Thu Feb 11 20:39:58 2016
OS/Arch: linux/amd64
最后,就可以下载镜像和运行容器了:
补充说明:
之前在Mac上使用brew安装的Docker,可以使用下面命令将其删除。
$brew uninstall docker
Uninstalling /usr/local/Cellar/docker/1.4.1... (9 files, 7.0M)
3 更多
[1] Mac OS X