Windows in a Box: Simplified Testing with Docker
Cross-Platform Testing
If you're building an application that needs to work on multiple operating systems, you can use this Docker image to quickly and easily test how your software behaves on Windows without needing a dedicated virtual machine or physical machine. This is great for CI/CD pipelines.
Sandboxed Environments
It provides a safe, isolated environment to test untrusted applications or scripts. You can run something in the container, and if it's malicious or unstable, it won't affect your host machine.
Automating Windows-Specific Tasks
You can use this image to automate tasks that require a Windows environment, like running PowerShell scripts, testing legacy applications, or using Windows-only command-line tools. This can be integrated into build scripts or automated workflows.
First, you'll need Docker installed on your machine. If you don't have it, you can get it from the Docker website.
Once Docker is ready, you can pull the dockur/windows image from Docker Hub. Just open your terminal or command prompt and run this command
docker pull dockur/windows
After the image is downloaded, you can run a container from it. The simplest way to run it is like this
docker run -it --rm dockur/windows
-it
This gives you an interactive shell inside the container.
--rm
This automatically removes the container when you exit, which is great for cleanup.
This will run a shell inside the Windows container. You can run Windows commands, but it's a very stripped-down environment. To get a more useful experience, you'll want to access the desktop, which requires a VNC client.
To see the Windows desktop, you need to expose the VNC port. By default, VNC runs on port 5900 inside the container. You'll map this to a port on your host machine.
Here's an example
docker run -p 5900:5900 --name my-windows-vm dockur/windows
-p 5900:5900
This maps port 5900 on your host to port 5900 in the container.
--name my-windows-vm
This gives the container a friendly name.
Once the container is running, you can connect to it using a VNC client. Just open your VNC client and connect to localhost:5900.
The default VNC password is vncpassword. You can change this when you run the container if you like.
Let's say you have a PowerShell script named test.ps1 on your host machine that needs to be executed on Windows. You can use the dockur/windows image to do this.
Create your PowerShell script (test.ps1)
Write-Host "Hello from Windows!"
Run the Docker container and mount the script
You can use a volume mount to make your local file accessible inside the container.
docker run --rm -v $(pwd):/data dockur/windows powershell.exe -ExecutionPolicy Bypass -File C:\data\test.ps1
--rm
Cleans up the container after it's done.
-v $(pwd):/data
This is the key part. It mounts your current directory ($(pwd)) to a /data directory inside the container. This makes your test.ps1 script available at C:\data\test.ps1.
powershell.exe -ExecutionPolicy Bypass -File C:\data\test.ps1
This is the command that gets executed inside the container. It runs your PowerShell script.
This command will output
Hello from Windows!