在windows使用docker根据官方文档安装的是Docker Desktop。Docker desktop是Microsoft Windows的Docker的社区版本。 我们可以从Docker Hub下载适用于Windows的Docker desktop。地址是:Docker Desktop for Windows。

系统要求

Windows 10 64位:专业版,企业版或教育版。
必须启用Hyper-V和Containers Windows功能。
要在Windows 10上成功运行Client Hyper-V,需要满足以下硬件先决条件:

具有二级地址转换(SLAT)的64位处理器
4GB系统内存
必须在BIOS设置中启用BIOS级硬件虚拟化支持。

注意:Docker基于Microsoft对Windows 10操作系统的支持生命周期在Windows上支持Docker Desktop。

此外,对于需要使用Docker Toolbox和Docker Machine的用户:运行Docker Desktop需要用到Microsoft Hyper-V。 必要时,Docker桌面Windows安装程序会启用Hyper-V,然后重新启动计算机。 启用Hyper-V后,VirtualBox就无法在使用。 但是,将保留所有现有的VirtualBox VM映像。

使用docker-machine创建的VirtualBox VM(包括通常在Toolbox安装期间创建的默认VM)不能再启动。 这些VM不能与Docker Desktop一起使用。 但是,我们仍然可以使用docker-machine管理远程VM

installer里面包含的东西

Docker Desktop installer包括Docker Engine,Docker CLI客户端,Docker Compose,Notary,Kubernetes和Credential Helper。

使用Docker Desktop创建的容器和映像在安装它的机器上的所有用户帐户之间共享。 这是因为所有Windows帐户都使用相同的VM来构建和运行容器。

windows上docker desktop安装流程

  1. 双击Docker Desktop Installer.exe运行安装程序。
  2. 如果尚未下载安装程序(Docker Desktop Installer.exe),则可以从Docker Hub中获取它。
  3. 按照安装向导上的说明接受许可证,授权安装程序,然后继续安装。
  4. 出现提示时,请在安装过程中使用您的系统密码授权Docker Desktop Installer。 需要特权访问才能安装网络组件,到Docker应用程序的链接以及管理Hyper-V VM。
  5. 在安装完成对话框上单击完成,然后启动Docker Desktop应用程序。

启动docker desktop

Docker Desktop在安装后不会自动启动。 要启动Docker Desktop,我们可以搜索Docker,然后在搜索结果中选择Docker Desktop。

当状态栏中的鲸鱼图标保持稳定时,Docker desktop已经启动并运行,并且我们可以从任何终端窗口访问。

我们可以创建docker账户,然后用docker账户登录docker desktop:

使用docker desktop

1.我们可以打开一个cmd窗口或者power shell

2.执行命令 docker --version

> docker --versionDocker version 19.03.1

3.从Docker Hub提取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:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Downloaded newer image for hello-world:latestHello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare 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/

4.List出从Docker Hub下载的hello-world映像:

> docker image ls

可以得到下面的内容

其中的hello-world就是刚刚落下来的image

5.list出hello-world 容器以及其他容器

> docker container ls --all

如果去掉命令最后的--all的话,则只会list出正在运行的容器。

6.我们还可以通过下面的命令来查看docker的其他功能

> docker --help
> docker container --help
> docker container ls --help
> docker run --help

使用docker application

1.提取Ubuntu OS的映像,并在生成的容器内运行交互式终端:

docker run --interactive --tty ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
5bed26d33875: Pull complete                                                                                                                                             f11b29a9c730: Pull complete                                                                                                                                             930bda195c84: Pull complete                                                                                                                                             78bf9a5ad49e: Pull complete                                                                                                                                             Digest: sha256:bec5a2727be7fff3d308193cfde3491f8fba1a2ba392b7546b43a051853a341d
Status: Downloaded newer image for ubuntu:latest
root@4c6071c62eed:/#         

2.运行成功之后我们就已经在容器中了。 在root#提示符下,检查容器的主机名:

root@4c6071c62eed:/# hostname
4c6071c62eed
root@4c6071c62eed:/#

请注意,主机名已分配为容器ID。

3.使用exit命令退出shell程序,这也会停止容器:

root@4c6071c62eed:/# hostname
4c6071c62eed
root@4c6071c62eed:/# exit
exit

4.使用下面的命令查看所有的container

 docker container ls --all

我们可以发现刚刚的Ubuntu也在里面了

docker container ls --all
CONTAINER ID        IMAGE                                               COMMAND                  CREATED             STATUS                        PORTS               NAMES
4c6071c62eed        ubuntu                                              "bash"                   5 minutes ago       Exited (0) 51 seconds ago                         goofy_goldberg
061f65b54169        hello-world                                         "/hello"                 49 minutes ago      Exited (0) 49 minutes ago                         pe

5.拉取并且运行Dockerized nginx Web服务器,名字叫做webserver:

docker run --detach --publish 80:80 --name webserver nginxUnable to find image 'nginx:latest' locallylatest: Pulling from library/nginxfdd5d7827f33: Pull completea3ed95caeb02: Pull complete716f7a5f3082: Pull complete7b10f03a0309: Pull completeDigest: sha256:f6a001272d5d324c4c9f3f183e1b69e9e0ff12debeb7a092730d638c33e0de3eStatus: Downloaded newer image for nginx:latestdfe13c68b3b86f01951af617df02be4897184cbf7a8b4d5caf1c3c5bd3fc267f

注意,如果80端口被占用了,那就需要换一个端口号,例如使用90:80。

6. 访问Web浏览器http:// localhost,会显示nginx起始页。 (如果是使用80端口号,则直接访问localhost即可,无需附加80,因为我们在docker命令中指定了80,而他是默认HTTP端口。否则就使用localhost:90的方式访问)

7.查看所有在运行的container

docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
e4295758bda5        nginx               "nginx -g 'daemon of…"   5 minutes ago       Up 5 minutes        0.0.0.0:90->80/tcp   webserver

8.通过我们为分配的名称(webserver)停止正在运行的nginx容器:

 >  docker container stop webserver

9.删除我们刚刚创建的container

docker container rm webserver goofy_goldberg peaceful_gagarin
webserver
goofy_goldberg
peaceful_gagarin

Kubernetes

Docker Desktop包含一个在Windows主机上运行的独立Kubernetes服务器,因此我们可以测试在Kubernetes上部署Docker work load的方式。

Kubernetes客户端命令kubectl已包括在内,并配置为连接到本地Kubernetes服务器。 如果我们自己安装了kubectl并指向其他环境,例如minikube或GKE集群,要确保更改上下文,以使kubectl指向docker-desktop.

Docker Desktop Dashboard

Docker Desktop dashboard是docker的UI工具,在2020年的release当中发布,在此之前有一款基于 Electron 开发的桌面客户端,名叫 Kitematic,会随着 Docker Toolbox 一起打包,包含在 Docker for Mac 和 Docker for Windows 中。Dashboard 也是基于 Electron 实现的。

Docker Desktop Dashboard提供了一个简单的界面,可以与容器和应用程序进行交互,管理应用程序的生命周期。 Dashboard  UI会显示所有正在运行,已停止和已启动的容器及其状态。 它提供了一个直观的界面,可以执行常见的操作来检查,交互和管理Docker对象,包括容器和基于Docker Compose的应用程序。

Docker Desktop Dashboard有这样一些优点:

  1. 在GUI从CLI获取信息
  2. 直接在UI中访问容器日志以搜索容器行为
  3. 从UI可以访问Compose application的日志
  4. 快速查看容器正在使用的端口
  5. 监视容器资源利用率

在Dashboard当中列出了我们所有的容器和应用,我们可以通过下面的命令创建和启动一个redis container,打开任何一个CLI,运行下面的命令:

docker run -dt redis

这个命令可以创建一个新的Redis容器。 在Dashboard中我们可以查看新的Redis容器:

接下来,我们可以来创建一个sample application, 我们可以从Docker  samples page, 下载voting app。 voting app是一个可在多个Docker容器中运行的分布式应用程序。

这个示例的voting app包括:

  1. Python或ASP.NET Core中的前端Web应用程序,可让在两个选项之间进行投票
  2. Redis或NATS队列收集新投票
  3. .NET Core,Java或.NET Core 2.1工作程序,它consume votes并将其存储
  4. 由Docker支持的Postgres或TiDB数据库
  5. 一个Node.js或ASP.NET Core SignalR Web应用程序,可实时显示投票结果

要启动应用程序,我们在CLI中切换至包含示例投票应用程序的目录,然后运行docker-compose up --build

如果一切顺利会看到如下的message:

docker-compose up --build
Creating network "example-voting-app-master_front-tier" with the default driver
Creating network "example-voting-app-master_back-tier" with the default driver
Creating volume "example-voting-app-master_db-data" with default driver
Building vote
Step 1/7 : FROM python:2.7-alpine
2.7-alpine: Pulling from library/python
Digest: sha256:d2cc8451e799d4a75819661329ea6e0d3e13b3dadd56420e25fcb8601ff6ba49
Status: Downloaded newer image for python:2.7-alpine---> 1bf48bb21060
Step 2/7 : WORKDIR /app---> Running in 7a6a0c9d8b61
Removing intermediate container 7a6a0c9d8b61---> b1242f3c6d0c
Step 3/7 : ADD requirements.txt /app/requirements.txt---> 0f5d69b65243
Step 4/7 : RUN pip install -r requirements.txt---> Running in 92788dc9d682...
Successfully built 69da1319c6ce
Successfully tagged example-voting-app-master_worker:latest
Creating example-voting-app-master_vote_1   ... done
Creating example-voting-app-master_result_1 ... done
Creating db                                 ... done
Creating redis                              ... done
Creating example-voting-app-master_worker_1 ... done
Attaching to db, redis, example-voting-app-master_result_1, example-voting-app-master_vote_1, example-voting-app-master_worker_1
...

但是博主在执行时遇到了一个错误:

Creating example-voting-app-master_vote_1 ... error
ERROR: for example-voting-app-master_vote_1  Cannot create container for service vote: status code not OK but 500: {"Message":"Unhandled exception: Drive has not been shared"}ERROR: for vote  Cannot create container for service vote: status code not OK but 500: {"Message":"Unhandled exception: Drive has not been shared"}
ERROR: Encountered errors while bringing up the project.

原因在于没有共享磁盘,右击docker desktop,就是电脑右下角的图标。点击“settings”再点击“resources”,“file sharing”,然后把磁盘都勾上,就可以了

设置完成之后,再次执行命令,可以看到下面的log

Starting redis                              ... done                                                               Starting example-voting-app-master_result_1 ... done                                                               Starting db                                 ... done                                                               Creating example-voting-app-master_vote_1   ... done                                                               Starting example-voting-app-master_worker_1 ... done                                                               Attaching to redis, db, example-voting-app-master_vote_1, example-voting-app-master_result_1, example-voting-app-master_worker_1
db        |
db        | PostgreSQL Database directory appears to contain a database; Skipping initialization
db        |
db        | LOG:  database system was interrupted; last known up at 2020-04-14 20:52:31 UTC
redis     | 1:C 15 Apr 2020 04:37:53.103 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis     | 1:C 15 Apr 2020 04:37:53.103 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=1, just started
redis     | 1:C 15 Apr 2020 04:37:53.103 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis     | 1:M 15 Apr 2020 04:37:53.105 * Running mode=standalone, port=6379.
redis     | 1:M 15 Apr 2020 04:37:53.105 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis     | 1:M 15 Apr 2020 04:37:53.105 # Server initialized
redis     | 1:M 15 Apr 2020 04:37:53.105 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis     | 1:M 15 Apr 2020 04:37:53.105 * Ready to accept connections
db        | LOG:  database system was not properly shut down; automatic recovery in progress
db        | LOG:  record with zero length at 0/16BCAF0
db        | LOG:  redo is not required
db        | LOG:  MultiXact member wraparound protections are now enabled
db        | LOG:  database system is ready to accept connections
db        | LOG:  autovacuum launcher started
result_1  | [nodemon] 2.0.3
result_1  | [nodemon] to restart at any time, enter `rs`
result_1  | [nodemon] watching path(s): *.*
result_1  | [nodemon] watching extensions: js,mjs,json
result_1  | [nodemon] starting `node server.js`
vote_1    |  * Serving Flask app "app" (lazy loading)
vote_1    |  * Environment: production
vote_1    |    WARNING: This is a development server. Do not use it in a production deployment.
vote_1    |    Use a production WSGI server instead.
vote_1    |  * Debug mode: on
vote_1    |  * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
vote_1    |  * Restarting with stat
worker_1  | Connected to db
worker_1  | Connecting to redis
worker_1  | Found redis at 172.21.0.2
result_1  | Wed, 15 Apr 2020 04:37:54 GMT body-parser deprecated bodyParser: use individual json/urlencoded middlewares at server.js:73:9
result_1  | Wed, 15 Apr 2020 04:37:54 GMT body-parser deprecated undefined extended: provide extended option at ../node_modules/body-parser/index.js:105:29
result_1  | App running on port 80
result_1  | Connected to db
vote_1    |  * Debugger is active!
vote_1    |  * Debugger PIN: 332-372-563

查看docker dash board,我们可以看到voting app及其组件已经成功运行了

我们可以在dashboard上看到正在运行的容器和应用程序的列表,除此之外,我们可以执行下面的操作

  1. 单击端口以在浏览器中打开容器公开的端口。
  2. 单击CLI打开终端并在容器上运行命令。
  3. 单击 StopStartRestart, 或 Delete以对容器执行生命周期操作。

然后我们可以单击application进入其CLI,这里我们可以看到这个应用的log,另外我们可以在底部搜索log并且copy

单击特定container可以获取有关该container的详细信息。 容器视图显示logs,inspect和stats选项卡,并提供操作按钮以执行各种操作。

选择logs以查看来自容器的日志。 还可以在日志中搜索特定事件,并将日志复制到剪贴板。

选择inspect以查看有关容器的底层信息。 您可以看到本地路径,映像的版本号,SHA-256,端口映射和其他详细信息。

选择stats信息以查看有关容器资源利用率的信息。 您可以看到容器使用的CPU,磁盘I / O,内存和网络I / O的数量。

还可以使用顶部栏上的快速操作按钮执行常见操作,例如打开CLI以在容器中运行命令,以及执行生命周期操作,例如停止,启动,重新启动或删除容器。

另外单击端口可以在浏览器中打开容器公开的端口,如果应用程序有UI则我们就可以直接访问他的UI了,例如voting app

windows下docker desktop的安装和使用相关推荐

  1. Windows 下 Docker 与 VMware 共存

    本文介绍一种使得 Windows 下 Docker 与 VMware 软件同时可用的方法. 2020年4月17日更新: VMware现已初步支持Hyper-V,并且WSL2也快正式发布,请考虑使用新的 ...

  2. Docker Desktop的安装及其使用

    文章目录 前言 一.Docker Desktop的安装 二.Docker Desktop的使用 1.Disk image location路径的修改 2.验证是否安装成功 三.Docker使用 1.镜 ...

  3. windows下使用批处理命令安装 tomcat 服务

    windows下使用批处理命令安装 tomcat 服务 1.准备 jdk的解压包 tomcat解压包 2.编写批处理命令(bat) 把jdk的解压包放到tomcat下的bin目录里(我这里直接使用的是 ...

  4. Windows下R语言环境安装

    Windows下R语言环境安装 R官网: https://www.r-project.org/ 按照如下步骤下载windows中的安装文件R-4.1.0-win.exe 文件已经下载完成:R-4.1. ...

  5. Windows下Go语言的安装和运行

    参考:https://blog.csdn.net/SquirrelYuyu/article/details/82776029 Windows下Go语言的安装和运行 文章目录 Go语言的安装与配置 Go ...

  6. Windows下VisualSVN Server的安装与配置方法(图文)

    这篇文章主要介绍了Windows下VisualSVN Server的安装与配置方法,比较详细,需要的朋友可以参考下 VisualSVN Server是免费的,而VisualSVN是收费的.Visual ...

  7. iis怎么更换php版本,Windows 下PHP+IIS的安装方法(PHP版本为5.0)

    Windows 下PHP+IIS的安装方法(PHP版本为5.0) 最近需要使用下PHP相关的东西,查找了一些资料,现将PHP配置方法记录一下,以免以后忘记,呵呵,初学者,各位同学不要拍砖,开始正题,主 ...

  8. windows 下的CACTI的安装方法

    windows 下的CACTI的安装方法 记得第一次工作的时候,主管非得让我学在windows 下的CACTI的安装,把我急的,明明是Linux下的东东,硬让我在windows下面装,不过有不敢不听话 ...

  9. windows下 python 使用 pip 安装TA-Lib报错的原因及解决方法

    windows下 python 使用 pip 安装TA-Lib报错的原因及解决方法 问题环境 问题描述 问题原因 & 解决办法 问题环境 Windows 10 x64 .python 3.8. ...

最新文章

  1. Nature子刊:三代测序重构菌株水平宏基因组序列的计算框架iGDA
  2. 半导体二极管和晶体三极管
  3. sql xml 入门
  4. 左神算法课笔记(一):时间复杂度、排序、对数器、二分法、异或运算
  5. 【editor】Source Insight定制之代码风格自动校准功能(AStyle的使用)
  6. ubuntu 20.04 DNS 设置
  7. slack 团队协作平台
  8. python去重排序_python读取TXT到数组及列表去重后按原来顺序排序的方法
  9. 最优比例生成树(0/1分数规划)
  10. 迫切想要成功之后的喜悦感,失败太久有点心灵上小小的打击,还需要继续前进。...
  11. Git问题解决:warning: Pulling without specifying how to reconcile divergent branches is discouraged. You
  12. 【QT】对话框dialog
  13. diskpart给u盘分区
  14. 世界最快超级计算机富岳系统采用DDN公司的存储产品
  15. AP计算机A自学笔记:程序分析
  16. 头歌:输入输出之计算圆周长与面积
  17. 搞懂这 10 张脑图后,我膨胀了。
  18. 安川服务器显示030,安川伺服驱动器常见故障报警代码解析
  19. ChatGPT 推出 iOS 应用,支持语音输入,使用体验如何?
  20. android购物车代码简述,Android实现简单购物车功能

热门文章

  1. 夜神MUMU模拟器找不到开发者选项
  2. java生成PDF(图片,模板,表格)
  3. 你不是脾气太坏,而是格局太小
  4. 单精度浮点数存储格式理解
  5. 黑马在线教育数仓实战8
  6. 项目引入js-cookie第三方库,报错问题,Vue3+TS
  7. 阿里云RDS 读写分离
  8. USB通讯基FPGA的CY7C68013A实现(2)
  9. 仿网易新闻客户端(二)
  10. 2019年最新易语言POST教程