当前位置: 首页 > news >正文

Win11配置wsl、ubuntu、docker

  • 系统要求

安装WSL。

开通虚拟化:

  • 准备工作
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

wsl --set-default-version 2
  • 安装WSL Ubuntu

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

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

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

    查看:

     wsl -l -v
      NAME            STATE           VERSION
    * Ubuntu-22.04    Running         2
    • 安装docker

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

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

    • 检查docker设置

    启动 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: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/
    • 允许非root用户运行docker
    sudo groupadd docker;
    sudo usermod -aG docker $USER

    相关文章:

  • 【哇! C++】内联函数、auto关键字、基于范围的for循环、指针空值nullptr
  • git bash在github的库中上传或更新本地文件
  • 本地部署Deepseek-R1模型指南:从Ollama安装到RAG应用
  • 【Linux】Ubuntu Linux 系统——Node.js 开发环境
  • Spring Security,servlet filter,和白名单之间的关系
  • C#中的GC机制简析
  • AI在电竞比分网中的主要应用场景
  • 关于AURIX在debug时elf文件丢失无法调试
  • MySQL binlog的三种模式
  • MYSQL批量UPDATE的两种方式
  • JS设计模式之单例原型
  • 【深度学习模型分类】
  • 深入解析系统调用接口(System Call Interface, SCI)
  • 使用C#元组实现列表分组汇总拼接字段
  • Android中解决Button组件英文全部自动大写的问题
  • Oracle临时表空间(基础操作)
  • 科技之光闪耀江城:2025武汉国际半导体产业与电子技术博览会5月15日盛大开幕
  • 基于阿里云可观测产品构建企业级告警体系的通用路径与最佳实践
  • 掌握 PHP 单例模式:构建更高效的应用
  • c语言样式主题 清爽风格 代码色彩 keil风格 适合单片机开发GD32 STM32等 cursor或者vscode 的settings.json文件
  • 东部沿海大省浙江,为何盯上内河航运?
  • 《五行令》《攻守占》,2个月后国博见
  • 独家 |《苏州河》上海上演,编剧海飞:上海的风能吹透我
  • 吉利汽车一季度净利润大增264%,称整合极氪后实现整体效益超5%
  • 车建兴被留置:跌落的前常州首富和红星系重整迷路
  • 中国人民银行等四部门联合召开科技金融工作交流推进会