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

相关推荐
gQ85v10Db6 小时前
Redis分布式锁进阶第十五篇:全系列终极收官复盘 + 全站锁规范归档 + 生产零故障长期运维兜底总方案
运维·redis·分布式
赵鑫亿6 小时前
ClawPanel — 开源 OpenClaw 智能管理面板,20+ 通道接入 / 多模型配置 / Docker 一键部署
docker·容器·开源
智能化咨询6 小时前
(112页PPT)德勤制造业企业数据治理平台规划方案(附下载方式)
大数据·运维·人工智能
时光之源6 小时前
安装WSL2后在其中安装Ubuntu24.04.4再安装OpenClaw全流程傻瓜式教学:WSL2 + Ubuntu 24.04 + OpenClaw
linux·运维·ubuntu·openclaw·龙虾
eastyuxiao6 小时前
流程图 + 配置清单 在团队 / 公司项目管理场景的落地应用
大数据·运维·人工智能·流程图
杨云龙UP6 小时前
Windows Server 2012 环境下 Oracle 11.2 使用 expdp 实现自动备份、异地复制与定期清理_20260504
服务器·数据库·windows·mysql·docker·oracle·容器
Jinkxs7 小时前
LoadBalancer- 常见负载均衡算法:轮询 / 加权轮询 / 最少连接等基础实现
运维·算法·负载均衡
eastyuxiao7 小时前
流程图 + 配置清单 在团队 / 公司运维场景的落地应用方法
运维·人工智能·流程图
切糕师学AI7 小时前
Docker CE 与 Docker Compose 详解:容器化引擎与多容器编排
docker·容器
拾光Ծ7 小时前
【Linux系统】进程信号(上)
linux·运维·服务器·面试·信号处理