Blog

Using WSL 2 on Windows Server 2022 to run Linux containers

Windows Subsystem for Linux 2 (WSL 2) is one of the most popular features for developers on Windows 10 and 11. It has recently been made available on Windows Server 2022. With this addition, you can now run Linux containers on WSL 2 on Windows Server 2022 for development and testing purposes.

 

Preparing your Windows Server 2022

WSL 2 on Windows Server 2022 has a different requirement than Windows 10 and 11. Before you get started with WSL 2, make sure your OS is up-to-date with the latest patches. WSL 2 requires at least the June 2022 patch Tuesday release, but it’s always a good practice to ensure the latest updates are installed. After that, all pre-requisites for WSL 2 to work on Windows Server 2022 can be implemented with:

wsl –install

Now you should have a fully functional Linux environment on your Windows Server 2022 host.

 

Install Docker on WSL 2 on Windows Server 2022

To install Docker on Windows Server 2022, you need to follow the instructions for the specific distribution you chose on the previous step. Here are the instructions for Ubuntu, according to Docker’s documentation page. On your Windows Server 2022, click the Start button, then click on the Ubuntu icon:

This will launch the WSL 2 console. You can now run commands on the Ubuntu Linux image as you would on a regular Linux environment. To get started, let’s update the apt package index and install packages to allow apt to use a repository over HTTPS:

sudo apt-get update
sudo apt-get install
ca-certificates
curl
gnupg
lsb-release

Now, let’s add Docker’s official GPG key:

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o /etc/apt/keyrings/docker.gpg

Use the following command to set up the repository:

echo
“deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu
$(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install the Docker engine:

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Now let’s verify the installation has been successfully completed:

sudo service docker start
sudo docker version

You should see the details of the Docker engine installed. That’s it. You can now run the regular Docker commands you are familiar with. In addition, you can run regular Windows containers on the same host:

 

Conclusion

WSL 2 can be used on Windows Server 2022 to run Linux containers on Windows Server 2022 for development and testing purposes. Please let us know your thoughts on this scenario on the comments below.

No Comments

Leave a Reply

Be More Productive with Outlook in TeamsNetApp Cloud Volume ONTAP (CVO) for Azure – EDA Benchmark and Best Practices

Contact Us

We are always here to help. Please reach out to us and we'll get back to you as soon as possible.

Address:

Maruti Court, Ground Floor
Mvuli Road, Nairobi, Kenya

Phone:

+254716973110

Hours:

Mon-Fri 8am – 5pm
Sat 9am – 1am
Sun & Holidays Closed




    Generated by Feedzy