
我们平时开发都是在windows的机器上进行,但是操作docker镜像是需要安装docker客户端的,本文将介绍在windows下安装docker客户端的两种方式。
这种方式是到docker官网下载一个安装文件 DockerDesktopInstaller.exe,然后傻瓜式安装即可,这也是docker官网推荐的方式。
下载地址为:https://www.docker.com/products/docker-desktop
但是,这种安装方式有几个前提:
Hyper-V
在控制面板\所有控制面板项\程序和功能->启用或关闭windows功能中开启。遗憾地是,我的电脑使用这种方式死活安装不成功,最后不得不放弃,寻找其它途径。
后面我发现了这种安装方式,也是下载一个安装文件 DockerToolbox-19.03.1.exe,然后傻瓜式安装即可。
这种方式与上面最大的区别是,这种是在本地装了一个virtual box,然后里面装了一个linux虚拟机来玩的;前一种安装方式是直接使用windows的虚拟化技术(真的很烂)。
下载地址为:https://get.daocloud.io/toolbox/
下载途径有很多,我这里只提供一种。
当然,这种方式也有一些前提:
安装完成后,桌面上出现三个图标。

双击DockerQuickStart快捷方式。
这时会让你选择命令行容器,这里选择前面顺带安装的git中的bash,路径大致为 D:\ProgramFiles\Git\bin\bash.exe。
第一次启动比较慢,多等一会,之后命令行容器可以输入命令,输入 docker version。
$ docker version
Client:
Version: 19.03.1
API version: 1.40
Go version: go1.12.7
Git commit: 74b1e89e8a
Built: Wed Jul 31 15:18:18 2019
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.4
API version: 1.40 (minimum version 1.12)
Go version: go1.12.10
Git commit: 9013bf583a
Built: Fri Oct 18 15:55:51 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683输出信息如上,表示docker客户端安装正常。
在命令行中输入 docker run hello-world,并回车,将自动拉取镜像。
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
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.
(amd64)
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
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/输出信息如上,表示docker客户端安装成功。
本章我们一起学习了安装docker客户端的两种方式,我们选择了通过docker toolbox来安装,这种方式会在本机安装virtual box虚拟机,通过虚拟机里面的linux来模拟docker的操作。