[点晴永久免费OA]Windows 11 已原生支持Docker,你不在需要额外安装 Linux Docker
当前位置:点晴教程→点晴OA办公管理信息系统
→『 经验分享&问题答疑 』
微软最近在 WSL 里塞进了一个隐藏大招——WSL Container,通过内置的 |
docker run -it ubuntu bash | wslc run -it ubuntu:latest bash | |
docker run -d -p 8080:80 --name web nginx | wslc run -d -p 8080:80 --name web nginx | |
docker ps | wslc container pswslc ps | |
docker ps -a | wslc container ps --all | |
docker stop web | wslc container stop webwslc stop web | |
docker start web | wslc container start webwslc start web | |
docker rm web | wslc container rm webwslc rm web | |
docker exec -it web bash | wslc exec -it web bash | |
docker logs web | wslc container logs web | |
docker images | wslc image lswslc images | |
docker pull nginx | wslc pull nginx | |
docker build -t app . | wslc build -t app . | |
docker rmi nginx | wslc image rm nginx |
⚠️
container/image子命令大多可省略,如wslc ps = wslc container ps,wslc rm web = wslc container rm web。
wslc run --rm hello-world
看到 "Hello from WSL container!" 就说明环境没问题了。
# 后台启动,映射端口
wslc run -d --rm -p 8080:80 --name web nginx
# Windows 访问测试
curl http://localhost:8080
# 查看
wslc ps
# 停止(带 --rm 的容器停止后自动删除)
wslc stop web
wslc run --rm -it ubuntu:latest bash
wslc run --rm -it -v ${PWD}:/app alpine:latest sh
# 容器内 /app 即 Windows 当前目录
wslc run --rm --gpus all pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime `
python -c "import torch; print(torch.cuda.is_available())"
wslc stats
除了 wslc 工具,WSL 平台本身也做了多项升级:
WSL 容器让 Windows 上的 Linux 容器开发变得原生、轻量、可编程——不需要 Docker Daemon,不需要额外虚拟化层。
目前还是预览版,但随着后续迭代,微软还会补充更多命令、优化性能、加入企业级管理功能。关注一波就对了。🍬
参考资料:Microsoft Learn - WSL 容器[1]
[1]Microsoft Learn - WSL 容器: https://learn.microsoft.com/zh-cn/windows/wsl/wsl-container
阅读原文:点击这里