windows安装docker

1. 查看windows相关配置

打开任务管理器(CTRL+ALT+ESC)-> 选择性能 -> CPU ->虚拟化,确认是否已启用

在这里插入图片描述

2. 开启 Hyper-v

在控制面板打开程序,然后点击启动或关闭windows功能
应用后根据提示重启电脑

3. 安装 WSL 2(Windows Subsystem for Linux version 2)

WSL 2提供了一个真实的Linux内核,可以在Windows上以接近原生性能运行Linux容器。下面是安装WSL 2的步骤:

3.1 设置

首先,需要启用Windows功能中的“适用于Linux的Windows子系统”和“虚拟机平台”。

  • 打开控制面板。
  • 点击“程序”。
  • 点击“启用或关闭Windows功能”。
  • 找到并勾选“适用于Linux的Windows子系统”和“虚拟机平台”。
  • 点击“确定”并重启计算机。

3.2 安装WSL 2

  • 在线安装
    • 以管理员身份打开PowerShell。
    • 运行以下命令以安装WSL 2并设置默认版本为2:
      wsl --install
      
      这个命令将自动安装最新的WSL Linux内核版本,并设置WSL 2为默认版本。
  • 离线安装
    • 下载Linux内核更新包:
    • 安装Linux内核:
      • 运行下载的更新包。
    • 设置WSL 2 为默认版本:
      • 打开以管理员权限的命令提示符或PowerShell。
      • 运行 wsl --set-default-version 2

3. 安装Linux发行版

  • 打开Microsoft Store,搜索并选择你喜欢的Linux发行版(例如Ubuntu)。点击“获取”安装。安装完成后,可以直接从开始菜单启动该Linux发行版。
  • 初始化Linux发行版
    • 当你第一次启动新安装的Linux发行版时,系统会要求你创建一个用户账户和密码。这些将用于登录Linux环境:
      • 启动Linux:
        - 从开始菜单中找到并启动你刚安装的Linux发行版。
      • 设置用户信息:
        - 按照提示设置你的用户名和密码。这些将是你在该Linux环境中的凭据。
  • 更新和升级Linux包
    sudo apt update && sudo apt upgrade
    

4 配置Docker在WSL 2中

4.1 启用WSL 2集成

  • 打开Docker Desktop。
  • 点击右下角的设置图标(齿轮图标)。
  • 在设置菜单中,选择“Resources”(资源),然后点击“WSL Integration”(WSL集成)。
  • 在WSL集成选项中,找到你安装的Linux发行版名称,并启用它。确保启用了“Enable integration - with my default WSL distro”(与我的默认WSL发行版启用集成)选项。
  • 点击“Apply & Restart”(应用并重启)以保存设置。

4.2 在Linux中安装Docker(可选)

如果你希望直接在WSL 2的Linux环境中运行Docker命令,还可以在Linux发行版中安装Docker。这可以通过以下命令完成:

sudo apt update
sudo apt install docker.io

4.3 配置无需sudo运行Docker命令(可选)

  • 为了在不使用sudo的情况下运行Docker命令,你可以将你的用户添加到docker组:
    sudo usermod -aG docker $USER
    
  • 然后,你可能需要注销并重新登录到你的Linux会话,或者重启WSL,以使这些更改生效:
    exit
    wsl --shutdown
    
  • 重新启动WSL后,再次登录,你应该可以无需sudo直接运行Docker命令。
Docker on Windows by Elton Stoneman English | 14 July 2017 | ISBN: 1785281658 | 358 Pages | AZW3/EPUB/MOBI/PDF (conv) | 23.77 MB Key Features Start building applications as Docker images and running containers in a Windows production environment Design and implement distributed applications that run across multiple networked containers Build a full Continuous Deployment pipeline for a .NET Core application running on Windows Book Description Docker has become hugely popular because it offers benefits at all stages of software design and delivery. Until recently, it was impossible to use a Windows Server platform to host the Docker Engine without adding an additional layer of virtualization. Starting with Windows Server 2016, you are able to use Docker on Windows and take advantage to easily build, deploy, and run Windows Containers. From building and running simple images to designing and implementing distributed applications, this book will teach everything you need to know while using Docker on Windows. You will start by installing Docker on different versions of Windows and Windows Server, and run a simple container to verify that the setup is working correctly. You will see how to build Docker images with a Dockerfile for a simple website, and then run it on Windows. Moving on, we'll cover the practical usage of Docker and the tools in the Docker ecosystem, such as Docker Compose, Docker Trusted Registry, and Docker Swarm Mode. Then, you'll be able to apply that knowledge by building a full continuous deployment pipeline for a .NET Core application running on Windows. We'll also dive deep into some of the core features of Docker, such as networking and security. At the end of the book, you'll be guided through a business case that will help you practically implement Docker in a real-world scenario. What you will learn Understand how Docker works, build images, and run containers Run Docker on different versions of Windows, and on the cloud with Azure Des
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值