你的位置:首页 > 互联网IT

Docker搭建Windows,容器搭建Windows,容器Windows,Docker-Windows

系统:linux,Debian/Ubuntu/CentOS

软件:Docker搭建Windows

功能:Docker搭建Windows

下载:

项目地址:https://github.com/dockur/windows

https://github.com/search?q=DOCKUR%2Fwindows&type=repositories


QQ截图20250211190020.jpg Docker搭建Windows,容器搭建Windows,容器Windows,Docker-Windows 互联网IT

第一步:docker容器安装


参考文章:https://m.012.ooo/?id=840


安装部署

RedHat / CentOS安装


curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sh quick_start.sh


http://目标服务器 IP 地址:目标端口/安全入口



Windows

Logo

Build Version Size Package Pulls


Windows inside a Docker container.


Features ✨

ISO downloader

KVM acceleration

Web-based viewer

Video ?

Youtube


Usage ?

Via Docker Compose:


services:

  windows:

    image: dockurr/windows

    container_name: windows

    environment:

      VERSION: "11"

    devices:

      - /dev/kvm

      - /dev/net/tun

    cap_add:

      - NET_ADMIN

    ports:

      - 8006:8006

      - 3389:3389/tcp

      - 3389:3389/udp

    stop_grace_period: 2m

Via Docker CLI:


docker run -it --rm -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN --stop-timeout 120 dockurr/windows

Via Kubernetes:


kubectl apply -f https://raw.githubusercontent.com/dockur/windows/refs/heads/master/kubernetes.yml

Compatibility ⚙️

Product Platform

Docker Engine Linux

Docker Desktop Linux

Docker Desktop macOS

Docker Desktop Windows 11

Docker Desktop Windows 10

FAQ ?

How do I use it?

Very simple! These are the steps:


Start the container and connect to port 8006 using your web browser.


Sit back and relax while the magic happens, the whole installation will be performed fully automatic.


Once you see the desktop, your Windows installation is ready for use.


Enjoy your brand new machine, and don't forget to star this repo!


How do I select the Windows version?

By default, Windows 11 Pro will be installed. But you can add the VERSION environment variable to your compose file, in order to specify an alternative Windows version to be downloaded:


environment:

  VERSION: "11"

Select from the values below:


Value Version Size

11 Windows 11 Pro 5.4 GB

11l Windows 11 LTSC 4.2 GB

11e Windows 11 Enterprise 5.8 GB

10 Windows 10 Pro 5.7 GB

10l Windows 10 LTSC 4.6 GB

10e Windows 10 Enterprise 5.2 GB

8e Windows 8.1 Enterprise 3.7 GB

7e Windows 7 Enterprise 3.0 GB

ve Windows Vista Enterprise 3.0 GB

xp Windows XP Professional 0.6 GB

2025 Windows Server 2025 5.0 GB

2022 Windows Server 2022 4.7 GB

2019 Windows Server 2019 5.3 GB

2016 Windows Server 2016 6.5 GB

2012 Windows Server 2012 4.3 GB

2008 Windows Server 2008 3.0 GB

2003 Windows Server 2003 0.6 GB

Tip


To install ARM64 versions of Windows use dockur/windows-arm.


How do I change the storage location?

To change the storage location, include the following bind mount in your compose file:


volumes:

  - /var/win:/storage

Replace the example path /var/win with the desired storage folder.


How do I change the size of the disk?

To expand the default size of 64 GB, add the DISK_SIZE setting to your compose file and set it to your preferred capacity:


environment:

  DISK_SIZE: "256G"

Tip


This can also be used to resize the existing disk to a larger capacity without any data loss.


How do I share files with the host?

Open 'File Explorer' and click on the 'Network' section, you will see a computer called host.lan. Double-click it and it will show a folder called Data, which can be bound to any folder on your host via the compose file:


volumes:

  -  /home/user/example:/data

The example folder /home/user/example will be available as  \\host.lan\Data.


Tip


You can map this path to a drive letter in Windows, for easier access.


How do I install a custom image?

In order to download an unsupported ISO image that is not selectable from the list above, specify the URL of that ISO in the VERSION environment variable, for example:


environment:

  VERSION: "https://example.com/win.iso"

Alternatively, you can also skip the download and use a local file instead, by binding it in your compose file in this way:


volumes:

  - /home/user/example.iso:/custom.iso

Replace the example path /home/user/example.iso with the filename of your desired ISO file, the value of VERSION will be ignored in this case.


How do I run a script after installation?

To run your own script after installation, you can create a file called install.bat and place it in a folder together with any additional files it needs (software to be installed for example).


Then bind that folder in your compose file like this:


volumes:

  -  /home/user/example:/oem

The example folder /home/user/example will be copied to C:\OEM during installation and the containing install.bat will be executed during the last step.


How do I perform a manual installation?

It's best to stick to the automatic installation, as it adjusts various settings to prevent common issues when running Windows inside a virtual environment.


However, if you insist on performing the installation manually, add the following environment variable to your compose file:


environment:

  MANUAL: "Y"

How do I change the amount of CPU or RAM?

By default, the container will be allowed to use a maximum of 2 CPU cores and 4 GB of RAM.


If you want to adjust this, you can specify the desired amount using the following environment variables:


environment:

  RAM_SIZE: "8G"

  CPU_CORES: "4"

How do I configure the username and password?

By default, a user called Docker is created during the installation, with an empty password.


If you want to use different credentials, you can change them in your compose file:


environment:

  USERNAME: "bill"

  PASSWORD: "gates"

How do I select the Windows language?

By default, the English version of Windows will be downloaded. But you can add the LANGUAGE environment variable to your compose file, in order to specify an alternative language:


environment:

  LANGUAGE: "French"

You can choose between: ?? Arabic, ?? Bulgarian, ?? Chinese, ?? Croatian, ?? Czech, ?? Danish, ?? Dutch, ?? English, ?? Estonian, ?? Finnish, ?? French, ?? German, ?? Greek, ?? Hebrew, ?? Hungarian, ?? Italian, ?? Japanese, ?? Korean, ?? Latvian, ?? Lithuanian, ?? Norwegian, ?? Polish, ?? Portuguese, ?? Romanian, ?? Russian, ?? Serbian, ?? Slovak, ?? Slovenian, ?? Spanish, ?? Swedish, ?? Thai, ?? Turkish and ?? Ukrainian.


How do I select the keyboard layout?

If you want to use a keyboard layout or locale that is not the default for your selected language, you can add the KEYBOARD and REGION variables with a culture code, like this:


environment:

  REGION: "en-US"

  KEYBOARD: "en-US"

Note


Changing these values will have no effect after the installation has been performed already. Use the control panel inside Windows in that case.


How do I connect using RDP?

The web-viewer is mainly meant to be used during installation, as its picture quality is low, and it has no audio or clipboard for example.


So for a better experience you can connect using any Microsoft Remote Desktop client to the IP of the container, using the username Docker and by leaving the password empty.


There is a RDP client for Android available from the Play Store and one for iOS in the Apple Store. For Linux you can use FreeRDP and on Windows just type mstsc in the search box.


How do I assign an individual IP address to the container?

By default, the container uses bridge networking, which shares the IP address with the host.


If you want to assign an individual IP address to the container, you can create a macvlan network as follows:


docker network create -d macvlan \

    --subnet=192.168.0.0/24 \

    --gateway=192.168.0.1 \

    --ip-range=192.168.0.100/28 \

    -o parent=eth0 vlan

Be sure to modify these values to match your local subnet.


Once you have created the network, change your compose file to look as follows:


services:

  windows:

    container_name: windows

    ..<snip>..

    networks:

      vlan:

        ipv4_address: 192.168.0.100


networks:

  vlan:

    external: true

An added benefit of this approach is that you won't have to perform any port mapping anymore, since all ports will be exposed by default.


Important


This IP address won't be accessible from the Docker host due to the design of macvlan, which doesn't permit communication between the two. If this is a concern, you need to create a second macvlan as a workaround.


How can Windows acquire an IP address from my router?

After configuring the container for macvlan, it is possible for Windows to become part of your home network by requesting an IP from your router, just like a real PC.


To enable this mode, add the following lines to your compose file:


environment:

  DHCP: "Y"

devices:

  - /dev/vhost-net

device_cgroup_rules:

  - 'c *:* rwm'

Note


In this mode, the container and Windows will each have their own separate IPs.


How do I add multiple disks?

To create additional disks, modify your compose file like this:


environment:

  DISK2_SIZE: "32G"

  DISK3_SIZE: "64G"

volumes:

  - /home/example:/storage2

  - /mnt/data/example:/storage3

How do I pass-through a disk?

It is possible to pass-through disk devices directly by adding them to your compose file in this way:


devices:

  - /dev/sdb:/disk1

  - /dev/sdc:/disk2

Use /disk1 if you want it to become your main drive (which will be formatted during installation), and use /disk2 and higher to add them as secondary drives (which will stay untouched).


How do I pass-through a USB device?

To pass-through a USB device, first lookup its vendor and product id via the lsusb command, then add them to your compose file like this:


environment:

  ARGUMENTS: "-device usb-host,vendorid=0x1234,productid=0x1234"

devices:

  - /dev/bus/usb

Important


If the device is a USB disk drive, please wait until after the installation is completed before connecting it. Otherwise the installation may fail, as the order of the disks can get rearranged.


How do I verify if my system supports KVM?

Only Linux and Windows 11 support KVM virtualization, macOS and Windows 10 do not unfortunately.


You can run the following commands in Linux to check your system:


sudo apt install cpu-checker

sudo kvm-ok

If you receive an error from kvm-ok indicating that KVM cannot be used, please check whether:


the virtualization extensions (Intel VT-x or AMD SVM) are enabled in your BIOS.


you enabled "nested virtualization" if you are running the container inside a virtual machine.


you are not using a cloud provider, as most of them do not allow nested virtualization for their VPS's.


If you do not receive any error from kvm-ok but the container still complains about KVM, please check whether:


you are not using "Docker Desktop for Linux" as it does not support KVM, instead make use of Docker Engine directly.


it could help to add privileged: true to your compose file (or sudo to your docker run command), to rule out any permission issue.


How do I run macOS in a container?

You can use dockur/macos for that. It shares many of the same features, except for the automatic installation.


Is this project legal?

Yes, this project contains only open-source code and does not distribute any copyrighted material. Any product keys found in the code are just generic placeholders provided by Microsoft for trial purposes. So under all applicable laws, this project will be considered legal.


Stars ?

Stars


Disclaimer ⚖️

The product names, logos, brands, and other trademarks referred to within this project are the property of their respective trademark holders. This project is not affiliated, sponsored, or endorsed by Microsoft Corporation.



翻译:


Docker 容器内的 Windows。


特点✨

ISO 下载器

KVM加速

基于 Web 的查看器

视频?

YouTube


用法?

通过 Docker Compose:


services:

  windows:

    image: dockurr/windows

    container_name: windows

    environment:

      VERSION: "11"

    devices:

      - /dev/kvm

      - /dev/net/tun

    cap_add:

      - NET_ADMIN

    ports:

      - 8006:8006

      - 3389:3389/tcp

      - 3389:3389/udp

    stop_grace_period: 2m

通过 Docker CLI:


docker run -it --rm -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN --stop-timeout 120 dockurr/windows

通过 Kubernetes:


kubectl apply -f https://raw.githubusercontent.com/dockur/windows/refs/heads/master/kubernetes.yml

兼容性⚙️

产品 平台

Docker 引擎 Linux

Docker 桌面 Linux

Docker 桌面 macOS

Docker 桌面 Windows 11

Docker 桌面 Windows 10

常见问题解答?

我如何使用它?

非常简单!步骤如下:


启动容器并使用您的 Web 浏览器连接到端口 8006 。


当奇迹发生时,您可以坐下来放松,整个安装过程将完全自动完成。


一旦看到桌面,就表示您的 Windows 安装已可供使用。


享受您的全新机器,并且不要忘记为这个 repo 加星标!


如何选择 Windows 版本?

默认情况下,将安装 Windows 11 Pro。但您可以将VERSION环境变量添加到 Compose 文件中,以指定要下载的备用 Windows 版本:


environment:

  VERSION: "11"

从以下值中选择:


价值 版本 尺寸

11 Windows 11 专业版 5.4 GB

11l Windows 11 LTSC 4.2 GB

11e Windows 11 企业版 5.8 GB

10 Windows 10 专业版 5.7 GB

10l Windows 10 LTSC 4.6 GB

10e Windows 10 企业版 5.2 GB

8e Windows 8.1 企业版 3.7 GB

7e Windows 7 企业版 3.0 GB

ve Windows Vista 企业版 3.0 GB

xp Windows XP 专业版 0.6 GB

2025 Windows Server 2025 5.0 GB

2022 Windows Server 2022 4.7 GB

2019 Windows 服务器 2019 5.3 GB

2016 Windows 服务器 2016 6.5 GB

2012 Windows 服务器 2012 4.3 GB

2008 Windows 服务器 2008 3.0 GB

2003 Windows 服务器 2003 0.6 GB

提示


要安装 ARM64 版本的 Windows,请使用dockur/windows-arm。


如何更改存储位置?

要更改存储位置,请在撰写文件中包括以下绑定挂载:


volumes:

  - /var/win:/storage

将示例路径替换/var/win为所需的存储文件夹。


如何更改磁盘大小?

要扩展 64 GB 的默认大小,请将DISK_SIZE设置添加到您的撰写文件中,并将其设置为您的首选容量:


environment:

  DISK_SIZE: "256G"

提示


这也可以用于将现有磁盘调整为更大的容量而不会丢失任何数据。


如何与主机共享文件?

打开“文件资源管理器”,点击“网络”部分,你会看到一台名为的计算机host.lan。双击它,它会显示一个名为的文件夹Data,可以通过撰写文件将其绑定到主机上的任何文件夹:


volumes:

  -  /home/user/example:/data

示例文件夹/home/user/example将以 形式提供 \\host.lan\Data。


提示


您可以将此路径映射到 Windows 中的驱动器号,以便于访问。


如何安装自定义图像?

为了下载上面列表中无法选择的不受支持的 ISO 映像,请在VERSION环境变量中指定该 ISO 的 URL,例如:


environment:

  VERSION: "https://example.com/win.iso"

或者,您也可以跳过下载并使用本地文件,通过以下方式将其绑定到您的撰写文件中:


volumes:

  - /home/user/example.iso:/custom.iso

将示例路径替换为您想要的 ISO 文件的文件名,在这种情况下将忽略/home/user/example.iso的值。VERSION


安装后如何运行脚本?

要在安装后运行您自己的脚本,您可以创建一个名为的文件install.bat并将其与其所需的任何附加文件(例如要安装的软件)一起放在文件夹中。


然后在您的撰写文件中绑定该文件夹,如下所示:


volumes:

  -  /home/user/example:/oem

示例文件夹/home/user/example将在安装过程中被复制到C:\OEM,并且包含install.bat将在最后一步执行。


如何进行手动安装?

最好坚持自动安装,因为它会调整各种设置以防止在虚拟环境中运行 Windows 时出现常见问题。


但是,如果您坚持手动执行安装,请将以下环境变量添加到您的撰写文件中:


environment:

  MANUAL: "Y"

如何更改 CPU 或 RAM 的数量?

默认情况下,容器最多允许使用 2 个 CPU 核心和 4 GB RAM。


如果您想调整这个,您可以使用以下环境变量指定所需的数量:


environment:

  RAM_SIZE: "8G"

  CPU_CORES: "4"

如何配置用户名和密码?

默认情况下,Docker安装过程中会创建一个名为的用户,其密码为空。


如果您想使用不同的凭据,您可以在撰写文件中更改它们:


environment:

  USERNAME: "bill"

  PASSWORD: "gates"

如何选择 Windows 语言?

默认情况下,将下载英文版 Windows。但您可以将LANGUAGE环境变量添加到 Compose 文件中,以指定替代语言:


environment:

  LANGUAGE: "French"

您可以选择:??阿拉伯语、??保加利亚语、??中文、??克罗地亚语、??捷克语、??丹麦语、??荷兰语、??英语、??爱沙尼亚语、??芬兰语、??法语、??德语、??希腊语、??希伯来语、??匈牙利语、??意大利语、??日语、??韩语、??拉脱维亚语、??立陶宛语, ?? 挪威语、?? 波兰语、?? 葡萄牙语、?? 罗马尼亚语、?? 俄语、?? 塞尔维亚语、?? 斯洛伐克语、?? 斯洛文尼亚语、?? 西班牙语、?? 瑞典语、?? 泰语、?? 土耳其语和?? 乌克兰语。


如何选择键盘布局?

如果您想要使用非所选语言默认的键盘布局或区域设置,则可以添加带有文化代码KEYBOARD的REGION变量,如下所示:


environment:

  REGION: "en-US"

  KEYBOARD: "en-US"

笔记


安装完成后,更改这些值将不会产生任何影响。在这种情况下,请使用 Windows 内的控制面板。


如何使用 RDP 连接?

网络查看器主要用于安装期间使用,因为它的图像质量较低,并且没有音频或剪贴板。


Docker因此,为了获得更好的体验,您可以使用任何 Microsoft 远程桌面客户端使用用户名并将密码留空来连接到容器的 IP 。


Play Store 提供适用于Android的 RDP 客户端, Apple Store 提供适用于iOS 的RDP 客户端。对于 Linux,您可以使用FreeRDPmstsc ;对于 Windows,只需在搜索框中输入即可。


如何为容器分配单独的 IP 地址?

默认情况下,容器使用桥接网络,与主机共享 IP 地址。


如果要为容器分配单独的 IP 地址,可以按如下方式创建 macvlan 网络:


docker network create -d macvlan \

    --subnet=192.168.0.0/24 \

    --gateway=192.168.0.1 \

    --ip-range=192.168.0.100/28 \

    -o parent=eth0 vlan

请务必修改这些值以匹配您的本地子网。


创建网络后,将撰写文件更改为如下所示:


services:

  windows:

    container_name: windows

    ..<snip>..

    networks:

      vlan:

        ipv4_address: 192.168.0.100


networks:

  vlan:

    external: true

这种方法的另一个好处是您不再需要执行任何端口映射,因为所有端口都会默认公开。


重要的


由于 macvlan 的设计不允许 Docker 主机与主机之间进行通信,因此无法从 Docker 主机访问此 IP 地址。如果担心此问题,您需要创建第二个 macvlan作为解决方法。


Windows 如何从我的路由器获取 IP 地址?

为macvlan配置容器后,Windows 就可以像真正的 PC 一样通过向路由器请求 IP 成为家庭网络的一部分。


要启用此模式,请将以下行添加到您的撰写文件中:


environment:

  DHCP: "Y"

devices:

  - /dev/vhost-net

device_cgroup_rules:

  - 'c *:* rwm'

笔记


在这种模式下,容器和 Windows 将各自拥有单独的 IP。


如何添加多个磁盘?

要创建其他磁盘,请像这样修改您的撰写文件:


environment:

  DISK2_SIZE: "32G"

  DISK3_SIZE: "64G"

volumes:

  - /home/example:/storage2

  - /mnt/data/example:/storage3

如何直通磁盘?

可以通过以下方式将磁盘设备添加到撰写文件中来直接传递磁盘设备:


devices:

  - /dev/sdb:/disk1

  - /dev/sdc:/disk2

/disk1如果您希望它成为主驱动器(将在安装期间格式化),请使用,并使用更高/disk2版本将其添加为辅助驱动器(将保持不变)。


如何直通 USB 设备?

要直通 USB 设备,首先通过lsusb命令查找其供应商和产品 ID,然后将它们添加到您的撰写文件中,如下所示:


environment:

  ARGUMENTS: "-device usb-host,vendorid=0x1234,productid=0x1234"

devices:

  - /dev/bus/usb

重要的


如果设备是 USB 磁盘驱动器,请等到安装完成后再连接。否则安装可能会失败,因为磁盘的顺序可能会重新排列。


如何验证我的系统是否支持 KVM?

只有 Linux 和 Windows 11 支持 KVM 虚拟化,遗憾的是 macOS 和 Windows 10 不支持。


您可以在Linux中运行以下命令来检查您的系统:


sudo apt install cpu-checker

sudo kvm-ok

如果您收到指示无法使用 KVM 的错误kvm-ok,请检查:


您的 BIOS 中已启用虚拟化扩展(Intel VT-x或)。AMD SVM


如果您在虚拟机内运行容器,则您启用了“嵌套虚拟化”。


您没有使用云提供商,因为大多数云提供商不允许其 VPS 进行嵌套虚拟化。


如果您没有收到任何错误kvm-ok但容器仍然抱怨 KVM,请检查:


您没有使用“Docker Desktop for Linux”,因为它不支持 KVM,而是直接使用 Docker Engine。


它可以帮助添加privileged: true到您的撰写文件(或sudo您的docker run命令)中,以排除任何权限问题。


如何在容器中运行 macOS?

您可以使用dockur/macos来实现这一点。除了自动安装之外,它们具有许多相同的功能。


这个项目合法吗?

是的,该项目仅包含开源代码,不分发任何受版权保护的材料。代码中找到的任何产品密钥都只是 Microsoft 为试用目的提供的通用占位符。因此,根据所有适用法律,该项目将被视为合法。


星星?

明星


免责声明⚖️

本项目中提及的产品名称、徽标、品牌和其他商标均属于其各自的商标持有者。本项目与 Microsoft Corporation 没有任何关联、赞助或支持。



参考来源:https://github.com/dockur/windows

https://github.com/search?q=DOCKUR%2Fwindows&type=repositories


  • 发表评论
  • 查看评论
【暂无评论!】

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。