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

相关推荐
Canmag 兴隆磁性3 小时前
中大型钕铁硼产品的磁通测量与自动分选:一条产线自动化的工程实现思路
运维·学习·自动化·永磁材料
xuefeiniao5 小时前
PHP2Shell漏洞修复
运维·服务器·php
便利店10246 小时前
系统活动一抓留存!深入 Linux C/C++ 调试工具之 sysdig
linux·运维·服务器·sysdig
智能运维指南7 小时前
企业 IT 运维自动化平台怎么选?从场景匹配到 POC 验证的完整评估框架
运维·自动化·自动化运维·嘉为蓝鲸
小马同学-8 小时前
K8s 控制器详解 — Deployment、ReplicaSet、DaemonSet 与 Job
云原生·容器·kubernetes
TTATTC8 小时前
单体应用如何支撑千所机构独立测评?拆解 sg-exam 行级多租户隔离与动态组卷内核
docker·开源
toooooop88 小时前
CentOS 7 内核 3.10.0-1160.119.1 升级指南
linux·运维·centos
TTATTC8 小时前
每加一个登录端都要改 Controller?Spring Boot 泛型策略工厂与模板切面演进
docker·开源
云飞云共享云桌面8 小时前
广东东莞制造工厂10人共享一台三维设计服务器
运维·服务器·3d·自动化·制造
程序员老赵8 小时前
Docker 部署 MaxKB:轻松搭建企业级智能体平台
前端·docker·agent