Win11配置wsl、ubuntu、docker

news/2025/3/12 12:18:57/
  • 系统要求

安装WSL。

开通虚拟化:

  • 准备工作
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartdism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestartwsl --set-default-version 2
  • 安装WSL Ubuntu

方式1(推荐):在Store中搜索Ubuntu,直接安装一个指定版本。

方式2:打开PowerShell,执行命令手动安装:wsl --install

    • 开始菜单中,找到刚刚安装的Ubuntu,运行(有时第一次会报错,再点几次)

    查看:

     wsl -l -vNAME            STATE           VERSION
    * Ubuntu-22.04    Running         2

    Docker Desktop: The #1 Containerization Tool for Developers | Docker

    在安装界面,勾选 “Enable the WSL 2 based engine”

    启动 Docker Desktop,进入设置:

    General页面,确认已启用 WSL 2 引擎。

    Resources页面 > WSL Integration。勾选你的 Linux 发行版(例如 Ubuntu),启用与 Docker 的集成。

    点击Apply & restart。

    • 打开Ubuntu
    docker --version
    Docker version 27.4.0, build bde2b89

    测试docker

    $ docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    e6590344b1a5: Download complete
    Digest: sha256:e0b569a5163a5e6be84e210a2587e7d447e08f87a0e90798363fa44a0464a1e8
    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/
    • 允许非root用户运行docker
    sudo groupadd docker;
    sudo usermod -aG docker $USER

    http://www.ppmy.cn/news/1573071.html

    相关文章

    俄罗斯方块游戏完整代码示例

    以下是一个基于Cocos Creator引擎开发的俄罗斯方块游戏的完整代码示例。该游戏实现了俄罗斯方块的基本功能,并且代码整合在单个文件中,无需任何外部依赖,可以直接在浏览器中运行。 1. 创建Cocos Creator项目 首先,确保你已经安装了…

    前端面试手写--虚拟列表

    目录 一.问题背景 二.代码讲解 三.代码改装 四.代码发布 今天我们来学习如何手写一个虚拟列表,本文将把虚拟列表进行拆分并讲解,然后发布到npm网站上. 一.问题背景 为什么需要虚拟列表呢?这是因为在面对大量数据的时候,我们的浏览器会将所有数据都渲染到表格上面,但是渲…

    利用SkinMagic美化MFC应用界面

    MFC(Microsoft Foundation Class)应用程序的界面设计风格通常比较保守,而且虽然MFC框架的控件功能强大且易于集成,但视觉效果较为朴素,缺乏现代感。尤其是MFC应用程序的设计往往以功能实现为核心,界面设计可能显得较为简洁甚至略显呆板,用户体验可能不如现代应用程序流畅…

    MapStruct 中 @BeforeMapping 和 @AfterMapping 注解的使用详解

    在使用 MapStruct 进行对象映射时,BeforeMapping和AfterMapping这两个注解能让开发者在映射前后执行自定义逻辑,极大地增强了映射的灵活性,满足多样化的业务需求。 一、BeforeMapping 注解 1.1 作用 BeforeMapping用于在映射方法执行前进行…

    如何将模型长度扩展到100万:Llama 3的NTK-aware插值技术解析 小学生都懂的

    好的,以下是对 Llama 3 如何通过 NTK-aware 插值 调整位置编码以扩展上下文长度到 100 万的详细原理解释: 1. RoPE(旋转位置编码)的原理 RoPE 是一种用于 Transformer 模型的位置编码方法,它通过旋转向量来注入位置信…

    Golang 语言的内存管理

    转载:Golang 语言的内存管理 内存分布 什么是虚拟内存? 计算机系统内存管理的一种技术。 每个进程都拥有独立的、连续的、统一的的虚拟地址空间。 通过 MMU 和物理内存映射,高效使用物理内存。 64 位 linux 进程内存分布情况 理论上有 16E 的…

    怎么理解 Spring Boot 的约定优于配置 ?

    在传统的 Spring 开发中,大家可能都有过这样的经历:项目还没开始写几行核心业务代码,就已经在各种配置文件中耗费了大量时间。比如,要配置数据库连接,不仅要在 XML 文件里编写冗长的数据源配置,还要处理事务…

    金融交易算法单介绍

    0.背景 股票交易时,常见的订单类型有基础订单和条件订单。 基础订单 市价单限价单碎股单等等 条件订单 止损市价单止损限价单触及市价单(止盈)触及限价单(止盈)跟踪止损市价单跟踪止损限价单等等 除了基础订单和…