首页 > 系统相关 >Docker for Windows 中文文档(1)——Explore the application and run examples

Docker for Windows 中文文档(1)——Explore the application and run examples

时间:2023-06-06 20:03:55浏览次数:49  
标签:Pull run complete Windows application version docker Docker Users


Get started with Docker for Windows

欢迎来到Docker for Windows!

Docker是用于创建集装箱应用程序的完整开发平台,Docker for Windows是在Windows系统上开始使用Docker的最佳方式。

检查Docker Engine,Compose和Machine的版本

启动您最喜欢的shell(cmd.exe,PowerShell或其他)来检查docker和docker-compose的版本,并验证安装。

C:\Users\rHotD>docker --version
Docker version 17.03.1-ce, build c6d412e

C:\Users\rHotD>docker-compose --version
docker-compose version 1.11.2, build f963d76f

C:\Users\rHotD>docker-machine --version
docker-machine version 0.10.0, build 76ed2a6

浏览应用程序并运行示例

接下来的几个步骤将会介绍一些例子。 这些只是在系统上试验Docker的方法的建议,检查版本信息,并确保docker命令正常工作。

1. 打开一个shell(cmd.exe,PowerShell或其他)。

2. 运行一些Docker命令,例如docker ps,docker版本和docker信息。

这是在powerhell中运行的docker ps的输出。 (在这个例子中,没有容器正在运行。)

C:\Users\rHotD>docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

以下是Docker版本的命令输出示例。

PS C:\Users\Docker> docker version
Client:
Version:      17.03.0-ce
API version:  1.26
Go version:   go1.7.5
Git commit:   60ccb22
Built:        Thu Feb 23 10:40:59 2017
OS/Arch:      windows/amd64

Server:
Version:      17.03.0-ce
API version:  1.26 (minimum version 1.12)
Go version:   go1.7.5
Git commit:   3a232c8
Built:        Tue Feb 28 07:52:04 2017
OS/Arch:      linux/amd64
Experimental: true

以下是docker信息的命令输出示例。

PS C:\Users\Docker> docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.03.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 977c511eda0925a723debdc94d09459af49d082a
runc version: a01dafd48bc1c7cc12bdb01206f9fea7dd6feb70
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.12-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934 GiB
Name: moby
ID: BM4O:645U:LUS6:OGMD:O6WH:JINS:K7VF:OVDZ:7NE4:ZVJT:PSMQ:5UA6
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 13
 Goroutines: 21
 System Time: 2017-03-02T16:59:13.417299Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

注意:上面的输出是例子。 您的输出,例如docker版本和docker信息,将取决于您的产品版本(例如,在安装较新版本时)。

3. 运行#docker run hello-world来测试从Docker Hub拉一张图像并启动一个容器。

C:\Users\rHotD>docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
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.
 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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

4. 尝试更有野心的东西,并使用此命令运行Ubuntu容器。

docker run -it ubuntu bash

这将下载ubuntu容器图像并启动它。 以下是在powerhell中运行此命令的输出。

C:\Users\rHotD>docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
c62795f78da9: Pull complete
d4fceeeb758e: Pull complete
5c9125a401ae: Pull complete
0062f774e994: Pull complete
6b33fd031fac: Pull complete
Digest: sha256:c2bbf50d276508d73dd865cda7b4ee9b5243f2648647d21e3a471dd3cc4209a0
Status: Downloaded newer image for ubuntu:latest
root@a8d217b930ac:/#

键入exit以停止容器并关闭powerhell

5. 使用此命令启动Dockerized Web服务器:

docker run -d -p 80:80 --name webserver nginx

这将下载nginx容器图像并启动它。 以下是在powerhell中运行此命令的输出。

PS C:\Users\jdoe> docker run -d -p 80:80 --name webserver nginx

Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx

fdd5d7827f33: Pull complete
a3ed95caeb02: Pull complete
716f7a5f3082: Pull complete
7b10f03a0309: Pull complete
Digest: sha256:f6a001272d5d324c4c9f3f183e1b69e9e0ff12debeb7a092730d638c33e0de3e
Status: Downloaded newer image for nginx:latest
dfe13c68b3b86f01951af617df02be4897184cbf7a8b4d5caf1c3c5bd3fc267f

6. 将您的Web浏览器指向http:// localhost以显示起始页。
(由于您指定了默认HTTP端口,因此无需在URL的末尾追加:80)

Docker for Windows 中文文档(1)——Explore the application and run examples_Docker

7. 当您的网络服务器正在运行时运行docker ps,以查看容器上的详细信息。

Docker for Windows 中文文档(1)——Explore the application and run examples_nginx_02

8. 停止或移除容器和图像。
nginx网络服务器将继续在该端口上的容器中运行,直到您停止和/或删除该容器。 如果要停止Web服务器,请键入:docker stop webserver,并使用docker start webserver重新启动它。

要使用单个命令停止并删除正在运行的容器,请键入:docker rm -f webserver。 这将删除容器,而不是nginx映像。 您可以列出本地图像与 docker 图像。 您可能想要保留一些图像,以便您不必再从Docker Hub中拉出。 要删除不再需要的图像,请使用docker rmi,然后使用图像ID或图像名称。 例如,docker rmi nginx


标签:Pull,run,complete,Windows,application,version,docker,Docker,Users
From: https://blog.51cto.com/u_16152603/6427432

相关文章

  • vSphere ESXi6.5创建Windows Server 2022虚拟机
    头一次操作,也踩了不少坑,故记录下一开始心里也没底,想着6.5的版本能支持2022嘛,新建的选项里最高也就2016,抱着试试看的心态装了下,没想到成了~ 1.下载iso镜像推荐渠道:MSDN:https://msdn.itellyou.cn/微软官网:https://www.microsoft.com/zh-cn/software-download/msdn老网站不......
  • UE5.1 中 Runtime Data Layer 的设置
    UE5.1中RuntimeDataLayer的设置UE5.1中奇葩的设置逻辑创建DataLayer默认是Editor的,5.1中如果想要修改为Runtime,需要进行如下设置在创建DataLayer之后,在ContentBrowser中右键点击它,点击Edit然后把DataLayerType设为Runtime我在DataLayerOutline......
  • mysql的ROUND、TRUNCATE函数
    在MySQL中,可以使用ROUND函数对数字进行四舍五入并保留指定位数的小数,语法如下:ROUND(number,decimals)其中,number参数表示要进行四舍五入的数字,decimals参数表示要保留的小数位数。例如,要对数字3.1415926进行四舍五入并保留两位小数,可以使用以下SQL语句:SELECTROUND(3.141592......
  • win10在Windows更新中出现 *某些设置由你的组织来管理
     1. 打开注册表编辑器。    快捷键(win+R)在运行窗口输入命令regedit 2. 定位到如下路径:  HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows  展开如果有WindowsUpdate子健的话,右键删除。  win10在Windows更新中出现*某些设置由你的组织来管理......
  • 《springboot冲刺棒》application.yml篇
    $是什么意思application.yml中的jdbc:mysql://${MYSQL-HOST:127.0.0.1}的$是什么意思application.yml中的${MYSQL-HOST:127.0.0.1}实际上是SpringBoot应用程序的属性占位符,具有允许在特定位置引用应用程序中定义的属性的功能。在这种情况下,${MYSQL-HOST:127.0.0.1}引用的......
  • 为了拒绝 Windows 所有可移动存储类的权限,请使用以下批处理脚本
    为了拒绝Windows所有可移动存储类的权限,请使用以下批处理脚本:CopyCoderegadd"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR"/v"Start"/tREG_DWORD/d4/fregadd"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor&qu......
  • maven-antrun-plugin
    1) 依赖 2)默认的classpath http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.htmlmaven.compile.classpathmaven.runtime.classpathmaven.test.classpathmaven.plugin.classpath3)示例<targetname="slice2java"><mk......
  • 数字取证-计算机取证篇-Windows计算机取证
    Windows计算机取证Windows现场取证流程去现场勘察之前要准备好案件同步,物证,取证工具,现场取证的U盘硬盘,录像机,物证袋,封条等等。收集相关的物证比如电脑,手机,外设(光盘,硬盘,U盘,数据连接线),设备等。如果计算机在开机状态要准备好在线取证,对于在计算机上正在运行的重要数据,重要程序......
  • Windows环境FFmpeg下载、环境变量配置
    FFmpeg官网下载地址第一步:点击Download下载按钮第二步:选择适合当前的运行环境,选择windows第一个地址Windowsbuildsfromgyan.dev第三步:选择releasebuilds中合适的版本第四步:环境变量配置,我安装的目录是:E:\ProgramFiles\ffmpeg-6.0-essentials_build点击ffmpeg安装......
  • 【Windows】Zookeeper伪集群安装
    下载zookeeper下载地址:http://archive.apache.org/dist/zookeeper/解压后,目录重命名为zookeeper1,进入conf目录,把zoo_sample.cfg复制一份,重命名为zoo.cfg。编辑zoo.cfg配置数据目录和日志目录先在zookeeper1目录下,新建目录data、logs#------------日志目录------------#......