2019独角兽企业重金招聘Python工程师标准>>>
使用DockerToolbox在MacOSX上安装Docker
这里利用 Docker Toolbox 来安装 Docker
注意:新版 Docker 版本为了支持 Docker 机不再支持 Boot2Docker 命令行
安装VirtualBox
首先需要安装[VirtualBox]虚拟机软件
地址是:https://www.virtualbox.org/
Step 1: Check your version 检测系统版本
OSX版本必须大于等于10.8 "Snow Leopard" 才可以安装 Docker Toolbox
Version: 10.11.2 (15C50)
Step 2: Install Docker Toolbox
点击 Docker Toolbox 下载链接,进行下载,由于AWS被墙,下载可能要麻烦一些了。
https://www.docker.com/toolbox
Step 3: Verify your installation
(1)Open the Launchpad and locate the Docker Quickstart Terminal icon. (2)Click the icon to launch a Docker Quickstart Terminal window. (3)Click your mouse in the terminal window to make it active. (4)Type the docker run hello-world command and press RETURN.
新创建一个Docker虚拟机
查看所有的Docker虚拟机 $ docker-machine ls
创建一个新的Docker虚拟机,命名为wangdev $ docker-machine create --driver virtualbox wangdev
$ docker-machine create --driver virtualbox wangdev
Running pre-create checks...
Creating machine...
(wangdev) Copying /Users/wangdev/.docker/machine/cache/boot2docker.iso to /Users/wangdev/.docker/machine/machines/wangdev/boot2docker.iso...
(wangdev) Creating VirtualBox VM...
(wangdev) Creating SSH key...
(wangdev) Starting the VM...
(wangdev) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
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 Docker to this machine, run: docker-machine env wangdev
根据创建成功后的提示,执行: docker-machine env wtest
$ docker-machine env wtest
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.102:2376"
export DOCKER_CERT_PATH="/Users/WangTom/.docker/machine/machines/wtest"
export DOCKER_MACHINE_NAME="wtest"
# Run this command to configure your shell:
# eval $(docker-machine env wtest)
再根据提示执行: eval $(docker-machine env wtest)
查看docker虚拟机列表:docker-machine ls
$ docker-machine ls NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS default - virtualbox Running tcp://192.168.99.101:2376 v1.9.1
wangdev * virtualbox Running tcp://192.168.99.102:2376 v1.9.1
可以看到 wangdev 在ACTIVE列变成了 星号 ,表示 wangdev 现在是激活状态。
执行 hello-world 容器看看效果:docker run hello-world
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b901d36b6f2f: Pull complete
0a6ba66e537a: Pull complete
Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
...
参考:
https://docs.docker.com/ https://docs.docker.com/mac/step_one/