Run Windows 11 in a Docker Container (Access it via the Browser)

Linux TLDR
Last Updated:
Reading time: 5 minutes

The Windows Docker container is gaining significant popularity, allowing users to easily deploy Windows 11, 10, 8.1, XP, etc., as a container and later access it via a browser (with VNC).

Before you confuse it with just a container, let me clarify that it uses Docker to download Windows images from the Microsoft server and then automatically configure it for installation, but behind the scenes, the downloaded image will be running in KVM (virtual emulator).

So, you need to ensure that virtualization is enabled in your BIOS settings, but the question arises: why do you need to run Windows in a Docker container then? The answer is quite simple. I’ve written a few points below that explain the advantages of running Windows in a Docker container.

  • It is completely free, open-source, and legal.
  • Automatically download the chosen Windows image from the Microsoft Server (for the latest Windows) or Bob Pony (for legacy Windows).
  • Easy access to Windows 11, 10, 8.1, 7, Vista, XP, or Windows Server 2022, 2019, 2016, 2012, 2008, and more.
  • It automatically configures the image and installs Windows, eliminating the need for going through manual installation. So, you can just run the Docker command and wait for your system to boot up.
  • Access your RAM, storage, GPU, USB devices, etc., within the container.
  • Easily delete and reinstall Windows like a sandbox.
  • Access Windows locally or remotely via a browser.
  • Use keyboard shortcuts through the remote desktop.
  • Access the Windows applications and games that Wine cannot handle properly.

Now, there are certain things (consider them cons) that you need to take care of; thus, they are.

  • Make sure that virtualization is enabled in the BIOS settings for Windows running in the Docker container, which uses KVM.
  • The Windows within the container remains unactivated (though activation is possible through a purchased license key).
  • Hardware devices like PCI and WiFi adapters cannot function (instead, opt for virtual machines).
  • It demands the same system requirements as the original Windows (thus, less RAM results in slower speeds).

So, let’s see how you can install and set up the Windows 11 Docker container and access it via a web browser in Linux (such as Debian, Ubuntu, Arch, RedHat, Fedora, etc.).

How to Setup a Windows 11 Docker Container on Linux

To set up a Windows 11 Docker container, you need to ensure that Docker and Docker Compose are installed and configured on your system, after which you can follow one of the below-mentioned methods to set it up based on your preference.

  • Using a single β€œdocker run” command (ease of use).
  • Using the β€œdocker-compose.yml” file (customization options are available).

I’ll explain how to set it up using both of these methods, so you can decide which is the perfect choice for you. Starting with…

Method 1: Using the Docker Run Command

This method is quite easy to follow because all you need to do is run the following command:

$ docker run -it --rm --name windows -v /var/win:/storage -p 8006:8006 -p 3389:3389 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 dockurr/windows

Whereas:

  • β€œdocker run -it --rmβ€œ: This is a Docker command to initiate a container in interactive mode, and with the β€œ--rm” option, the container will be removed once terminated.
  • β€œ--name windowsβ€œ: This sets the name of the container (which you can verify using the β€œdocker ps” command).
  • β€œ-v /var/win:/storageβ€œ: The downloaded image and configuration files will be stored here, so later, when the container is reinitialized, you do not have to start from scratch.
  • β€œ-p 8006:8006 -p 3389:3389β€œ: This exposes port 8006 for browser access through VNC and port 3389 for remote desktop. If you do not plan to use remote desktop, then remove the β€œ-p 3389:3389” part.
  • β€œ--device=/dev/kvmβ€œ: Specifies the KVM file.
  • β€œ--cap-add NET_ADMINβ€œ: Grants additional network capabilities to the container.
  • β€œ--stop-timeout 120β€œ: Specifies a grace period in seconds (in this case, 120) for a running container to shut down gracefully before it is forcefully terminated.
  • β€œdockurr/windowsβ€œ: This is the image of the container.

Once you issue the command, you can check the status of the Windows 11 container by visiting β€œhttp://localhost:8006” in your browser.

Method 2: Using Docker Compose File

This method is for advanced users, as it requires a few manual steps to create the Windows 11 container using a compose file. So, to begin, first create a directory, and inside it, create a compose file with the following commands:

$ mkdir ~/Windows-Docker && cd ~/Windows-Docker
$ touch docker-compose.yml

Now, within the compose file, you can copy and paste the following compose template, which I manually adjusted while keeping customization and ease of use in mind. Feel free to change the highlighted red values according to your preferences.

version: "3"
services:
  windows:
    image: dockurr/windows
    container_name: windows
    devices:
      - /dev/kvm
    cap_add:
      - NET_ADMIN
    ports:
      - 8006:8006
      - 3389:3389/tcp
      - 3389:3389/udp
    stop_grace_period: 2m
    restart: on-failure
    environment:
      VERSION: "win11"
      RAM_SIZE: "4G"
      CPU_CORES: "4"
      DISK_SIZE: "64G"
    volumes:
      - /var/win:/storage

In the above compose template, most of the stuff is the same as the previously mentioned β€œdocker run” command in method 1, so if you are directly visiting this method, make sure to first check that out.

The remaining options, which are new and consist of environment parameters such as β€œRAM_SIZEβ€œ, β€œCPU_CORESβ€œ, and β€œDISK_SIZEβ€œ, can be adjusted based on your preference and ensure that your system has the specified resources.

Now, once you have copied and pasted the provided compose template into the compose file, you can save, close the file, and execute the following command to start the container.

$ docker compose up -d

How to Access Windows 11 Running on a Docker Container

Once the container is initialized, it will begin downloading the mentioned Windows image, extracting it, and building it. You can open your favorite Firefox or Chrome browser and visit β€œhttp://localhost:8006” to monitor the status of your container.

The following is a picture of when the Windows 11 image is being downloaded.

window image is downloading

Once the download process is complete, it will automatically begin installing Windows 11 in a Docker container without requiring any manual steps.

windows 11 is installed in docker container

This process will take a few minutes, so you can take a coffee break and come back when you see the following Windows 11 home screen.

windows 11 home screen

Congratulations! You have successfully set up a Windows 11 Docker container on your Linux system. Now, below, I’ve attached a few images of running different applications to give you an idea of how they look.

The following is an image of Notepad running on a Windows 11 Docker container:

running notepad in windows 11 docker container

The following is an image of File Explorer on a Windows 11 Docker container:

file explorer in windows 11

The following is an image of the Control Panel on a Windows 11 Docker container:

control panel in windows 11 container

That’s it. Now you can use it like your regular Windows 11 machine on your Linux system without a virtual machine. Once you’re done using it, you can terminate it from your terminal.

Additional Tips on Using Windows on a Docker Container

Instead of accessing the Windows 11 Docker container from your browser through VNC, I would suggest you first enable remote desktop from Windows settings and then access it via a remote desktop client application to easily use keyboard shortcuts and achieve a proper screen view.

Now, in this article, we focus on setting up a Windows 11 container, but you can set up different Windows versions, such as 10, 8.1, 7, XP, or Windows Server, by simply replacing β€œwin11” from β€œVERSION: "win11"” under environment in the compose file with the value mentioned in the following tables.

ValueDescriptionSourceTransferSize
win11Windows 11 ProMicrosoftFast6.4 GB
win10Windows 10 ProMicrosoftFast5.8 GB
ltsc10Windows 10 LTSCMicrosoftFast4.6 GB
win81Windows 8.1 ProMicrosoftFast4.2 GB
win7Windows 7 SP1Bob PonyMedium3.0 GB
vistaWindows Vista SP2Bob PonyMedium3.6 GB
winxpWindows XP SP3Bob PonyMedium0.6 GB
2022Windows Server 2022MicrosoftFast4.7 GB
2019Windows Server 2019MicrosoftFast5.3 GB
2016Windows Server 2016MicrosoftFast6.5 GB
2012Windows Server 2012 R2MicrosoftFast4.3 GB
2008Windows Server 2008 R2MicrosoftFast3.0 GB
core11Tiny 11 CoreArchive.orgSlow2.1 GB
tiny11Tiny 11Archive.orgSlow3.8 GB
tiny10Tiny 10Archive.orgSlow3.6 GB

Final Word

I find it very interesting to use a Windows machine within a Docker container, with the added benefit of its automatic installation process eliminating the need for manual steps. However, you can opt for manual installation by specifying β€œMANUAL: "Y"” in the environment.

Another great aspect of using it is running legacy games on your system that require older versions of Windows, or free games shipped with Windows XP and 7. It’s better for running most applications that the Windows compatibility layer (such as Wine) can’t handle.

However, I want to know if you find it interesting and, if so, what you plan to use it for. Let me know in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.

1 thought on β€œRun Windows 11 in a Docker Container (Access it via the Browser)”

  1. We had to remove the windows 11 container complely using rm
    because when we ran the docker compose and changed to another windows OS, windows 11 would run not the other OS.
    So is this the case that only one container can exist?

    Thanks.

    Reply