WSL & Docker

Running Ubuntu with WSL ..

WSL & Docker

Using WSL and Docker for LLMs

Windows Subsystem for Linux (WSL) paired with Docker creates a powerful environment for working with Large Language Models. WSL provides a Linux-compatible kernel interface on Windows, allowing developers to run Linux tools directly alongside their Windows applications. When combined with Docker's containerization capabilities, this setup enables consistent deployment of LLM environments across different machines while isolating dependencies.

Docker containers package everything needed to run an LLM—from specific Python versions to specialized CUDA drivers for GPU acceleration—making it straightforward to deploy models like Llama, Mistral, or other open-source LLMs locally. This approach simplifies environment management, reduces "works on my machine" problems, and makes scaling from development to production more seamless, all while preserving Windows as your primary operating system.

WSL

Windows Subsystem for Linux (WSL) enables developers to run a GNU/Linux environment on Windows. The Ubuntu distribution for WSL is tightly integrated with the Windows OS, supporting features including remote development with popular IDEs and cross-OS file management.

Ubuntu on WSL provides a productive terminal environment that can also be used to launch Linux-native graphical applications.

There are multiple ways of installing distros on WSL:

  • Microsoft Store application

  • WSL commands run in the terminal


PowerShell

  1. List available versions.

wsl --list --online
List of Distros
  1. Install a version using a NAME from the output

wsl --install -d Ubuntu-24.04
  1. You’ll see an indicator of the installation progress in the terminal.

Ubuntu installation
  1. Once completed you have access to the WSL subsystem.

WSL
  1. Launch Unbuntu 24.04 LTS.

wsl.exe -d Ubuntu-24.04
  1. Enter username & password.

Once it has finished its initial setup, you will be prompted to create a username and password.

They don’t need to match your Windows user credentials.

Launch Ubuntu 24.04 LTS
  1. Close and open a new Terminal.

  2. Check all your currently installed distros and the version of WSL.

wsl -l -v
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\jpore> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-24.04    Stopped         2
PS C:\Users\jpore>

Run and configure Ubuntu

  1. Select Ubuntu 24.04 from the drop-down terminal.

Select Ubuntu 24.02 LTS

2. Install the latest updates.

sudo apt update && sudo apt full-upgrade -y
Update & Upgrade

Network

WSL doesn't connect to the internet from within the distro. The reason is because Windows automatically generates resolv.conf file with the wrong nameserver.

You may also need to stop WSL from resetting this file when opening future terminals

  1. Check if you already have internet connectivity.

ping google.com
  1. Check /etc/resolv.conf.

cat /etc/resolv.conf
  1. Create a proper resolv.conf.

sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "nameserver 8.8.4.4" >> /etc/resolv.conf'
  1. Generate a new /etc/wsl.conf file. This will prevent the resolv.conf being recreated on each session.

sudo bash -c 'cat > /etc/wsl.conf << EOF
[network]
generateResolvConf = false
EOF'
  1. Restart WSL.

wsl --shutdown

Last updated