【Windows安装Docker】

【一】引入

  • 在上一章节已经成功的在Linux CentOS 8.4远程服务器中安装了Docker,下面让我们一起来试试如何在Windows10中安装Docker并运行起来。
  • 有人说你既然在Linxu环境中安装了Docker了,为什么还要到Windows环境中去折腾一个Dokcer环境呢?这不是在浪费时间内。
  • 那么那就大错特错了,在Windows环境中安装一个Dokcer是为了便于我们在自己的Windows开发环境中快速打搭建你所需要的开发运行的软件环境而准备的比如说有时候你本地需要在Windows10开发环境中快速搭建一个Ms SQLServer的运行环境,但是大家在Windows环境安装过的都知道Ms SQLServer安装快则半个到一个小时,忙的话就是两三个小时不等。
  • 但是你使用Docker的话,下载镜像到运行容器在到配置可能就是十多分钟的功夫吧。
  • 好了废话不对说,下面我们开始来配置Window10下的Docker环境吧。

【二】Docker Desktop 介绍

  • Docker Desktop是适用于Windows的Docker桌面,是Docker设计用于在Windows 10上运行。
  • 它是一个本地 Windows 应用程序,为构建、交付和运行dockerized应用程序提供易于使用的开发环境。
  • Docker Desktop for Windows 使用 Windows 原生 Hyper-V 虚拟化和网络,是在 Windows 上开发 Docker 应用程序的最快、最可靠的方式。
  • Windows 版 Docker 桌面支持运行 Linux 和 Windows Docker 容器。

【三】Dokcer Desktop下载

【四】启用Hyper-V

注意:可以通过多种方式启用 Hyper-V,包括使用 Windows 10 控制面板、PowerShell(Hyper-V 作为可选功能内置于 Windows -- 无需下载 Hyper-V)。

【1】使用 PowerShell 启用 Hyper-V

  • 以管理员身份打开 PowerShell 控制台,运行以下命令:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

【2】通过控制面板“设置”启用 Hyper-V 角色

  • 右键单击 Windows 按钮并选择“应用和功能”。
  • 选择相关设置下右侧的“程序和功能”。

  • 选择“打开或关闭 Windows 功能”。

  • 选择“Hyper-V”,然后单击“确定”。

  • 注意:安装完成后,系统会提示你重新启动计算机。
  • 打开任务管理器,在性能页面可以看到,虚拟化已启用

【五】安装Docker Desktop

  • 双击下载成功的Docker Desktop Installer.exe应用。

  • 点击OK
    • 这是使用 WSL2进行安装而不是 Hyper-V
      • 我们将 USE WSL 去掉,我们使用 Hyper-V (后面试了 WSL 一直报错运行不起来)

  • 安装过程

  • 安装成功并启动

【六】配置阿里云镜像加速地址

【七】在Docker Desktop设置中配置阿里云镜像源

  • 在系统右下角托盘图标内右键菜单选择 Settings,打开配置窗口后左侧导航菜单选择 Docker Desktop。
    • 编辑窗口内的JSON串,填写下方加速器地址:
{ "registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"] }

【八】Windows PowerShell查看Docker版本

docker version
C:\Users\Administrator>docker version Client: Cloud integration: v1.0.35-desktop+001 Version: 24.0.5 API version: 1.43 Go version: go1.20.6 Git commit: ced0996 Built: Fri Jul 21 20:36:24 2023 OS/Arch: windows/amd64 Context: default Server: Docker Desktop 4.22.1 (118664) Engine: Version: 24.0.5 API version: 1.43 (minimum version 1.12) Go version: go1.20.6 Git commit: a61e2b4 Built: Fri Jul 21 20:35:45 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.21 GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8 runc: Version: 1.1.7 GitCommit: v1.1.7-0-g860f061 docker-init: Version: 0.19.0 GitCommit: de40ad0

【九】验证Docker桌面版 可以正常使用

  • 打开命令行窗口运行以下命令:
docker run hello-world
  • 看到以下输出则表示安装成功,且能正常工作:
C:\Users\Administrator>docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 2db29710123e: Pull complete Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f 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/

【十】拉取镜像测试

【十一】通过启用WSL2安装Docker(不建议)

  • 注意:通过启用Hyper-v虚拟化的方式在windows中安装Dokcer以外,我们还可以通过安装配置WSL2环境来安装。
  • WSL2 是 Windows Subsystem for Linux 二代的简称,WSL2允许用户在Windows上运行受支持的Linux发行版。
  • 当前的Docker桌面版可以使用WSL2作为其Linux后台运行。
  • 因此我们需要首先在Windows操作系统上激活WSL2功能才能使用Docker做面板。

__EOF__

本文作者Chimengmeng
本文链接https://www.cnblogs.com/dream-ze/p/17671808.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   Chimengmeng  阅读(1125)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示