Web Analytics

windows-in-docker-container

⭐ 115 stars Simplified Chinese by vaggeliskls

💻 在 Docker 容器中运行 Windows

探索一种创新且高效的方法,利用 Vagrant 虚拟机、libvirt 和 docker-compose 的力量,在您的 Linux 系统上部署 Windows 操作系统(x64)。这些技术共同帮助您将 Windows 操作系统容器化,使您能够像管理任何 Docker 容器一样管理 Windows 实例。这种无缝集成到现有工作流程中,大大提升了便利性并优化了资源分配。

如果本项目对您有帮助,别忘了给项目点星!

📋 先决条件

确保您的系统满足以下要求:

🚀 部署指南

# Vagrant image settings
MEMORY=8000     # MiB (~8 GB)
CPU=4
DISK_SIZE=100   # GiB
services:
  win10:
    image: docker.io/vaggeliskls/windows-in-docker-container:latest
    platform: linux/amd64
    env_file: .env
    stdin_open: true
    tty: true
    privileged: true
    cgroup: host
    restart: always
    ports:
      
  • 3389:3389
  • 2222:2222
  • 当您希望虚拟机持久化时,创建 docker-compose.override.yml
  • services:
      win10:
        volumes:
          
    • libvirt_data:/var/lib/libvirt
    • vagrant_data:/root/.vagrant.d
    • vagrant_project:/app/.vagrant
    • libvirt_config:/etc/libvirt
    volumes: libvirt_data: name: libvirt_data vagrant_data: name: vagrant_data vagrant_project: name: vagrant_project libvirt_config: name: libvirt_config
    > 首次启动需要几分钟时间 — Vagrant盒子已内置于镜像中,但虚拟机仍需启动并运行配置脚本(Chocolatey安装、磁盘扩展、注册表调整)。可通过 docker compose logs -f 查看进度。

    如果想销毁所有内容,执行 docker compose down -v

    windows screenshot

    🌐 访问

    远程桌面 (RDP)

    用于调试或测试,可通过端口 3389 使用 远程桌面 连接虚拟机。

    #### 远程桌面访问软件 | 操作系统 | 软件 | |------------|------------| | Linux | rdesktoprdesktop :3389Remmina | | MacOS | Microsoft Remote Desktop | | Windows | 内置 远程桌面连接 |


    SSH

    您可以使用 administratorVagrant 用户凭据通过 SSH 连接。

    ssh @ -p 2222

    🔑 用户登录

    基于 Vagrant 镜像的默认用户为:

    ⚠️ 限制

    🔧 故障排除

    📚 进一步阅读与资源

    --- Tranlated By Open Ai Tx | Last indexed: 2026-07-15 ---