DEV Community

Cover image for Windows VM Inside a Linux Docker Container
vaggeliskls
vaggeliskls

Posted on β€’ Edited on

9

Windows VM Inside a Linux Docker Container

When it comes to creating reproducible and isolated development environments, two leading technologies reign: Docker and Vagrant. Docker facilitates containerization by bundling applications and dependencies together, making the applications platform-independent. On the other hand, Vagrant is a tool for virtual environments, allowing the creation and management of virtual machines (VMs). Running a Vagrant VM, particularly a Windows VM, inside a Docker container creates a unique combination that can offer remarkable benefits, especially in the field of Continuous Integration (CI) and Continuous Deployment (CD). πŸ”‚ πŸš€

Today, we'll tap into an existing GitHub repository that demonstrates how to implement a Windows VM within this Docker/Vagrant setup. The repository can be found at the following URL: https://github.com/vaggeliskls/windows-in-docker-container

Prerequisites πŸ“‘

Before proceeding, the following tools should be installed on your system:

How to Use It πŸ› οΈ

  1. Create an environmental file .env with VMs specifications
# Vagrant image settings
MEMORY=8000 # 8GB
CPU=4
DISK_SIZE=100
Enter fullscreen mode Exit fullscreen mode
  1. Create a docker-compose.yml file
version: "3.9"

services:
  win10:
    image: docker.io/vaggeliskls/windows-in-docker-container:latest
    env_file: .env
    stdin_open: true
    tty: true
    privileged: true
    cgroup: host
    restart: always
    ports:
      - 3389:3389
      - 2222:2222
Enter fullscreen mode Exit fullscreen mode
  1. Run: docker-compose up -d

Windows vm screenshot

Remote Desktop πŸ–₯️

For debugging purposes or testing, you can always connect to the VM with remote desktop software products. Some software that used when developed was:

User login πŸ‘€

The default users based on vagrant image are

  • Administrator
    • Username: Administrator
    • Password: vagrant
  • User
    • Username: vagrant
    • Password: vagrant

Conclusion πŸ‘‹

Running a Vagrant Windows VM inside a Docker container merges the benefits of Docker's platform-independent containerization with Vagrant's controlled, easy-to-manage development environments. Although such a setup won't fulfill every use case, understanding how Docker and Vagrant operate and interact is highly beneficial for DevOps professionals.

Remember, different configurations exist and this setup can be tweaked to suit specific application requirements. Be aware that running a VM inside a Docker container can be resource-intensive, so always check your system's specifications before proceeding. πŸ“

Happy coding!

References πŸ“š

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post β†’

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more