Set up your PC to run devcontainers in VC Code #5
Replies: 2 comments
|
Tip Use the Instead of locating and hacking the
Example: (use in the instructions above) # Configure the GitHub MCP server
code --add-mcp '{"name":"io.github.github/github-mcp-server","type":"http","url":"https://githubcopilot.com","gallery":"https://api.mcp.github.com","version":"0.30.3"}'
|
|
Caution The previous instructions created a bit of a mess in the Windows install. In the previous instructions the installation of wsl, and then installation of Ubuntu 24-04 were split in two seperate commands (in PowerShell) wsl --install
winget install Canonical.Ubuntu.2404But the WSL default installs Ubuntu and then manual install added Ubuntu 24.04 we ended up with two different Ubuntu distros. Which caused quite some confusion. This is now locked in with the following step: # 4. Install WSL with Ubuntu 24.04 directly
wsl --install --distribution Ubuntu-24.04Here's an instruction on how to clean it up, if you ended with two distros. # see the distros you have
wsl --list --verbose
# Set Ubuntu 24-04 as the default
wsl --set-default Ubuntu-24.04
# Unregister the one you don't need
wsl --unregister Ubuntu...and then you may have to have to run the Ubuntu setup instructions — and the rest of the steps in the instruction — again. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The repositories we set up are all standardized in a way that are defined by Devcontainers. While these are theoretically also supported by GitHub Code Spaces, the more satisfying — and recommended — experience is to run them locally on your PC.
Setup your PC to support Docker engine, VS Code and Git
You need your PC (host) to support:
These are the only system requirements you have, everything else you need is self-contained in the repos.
The DevX promise
The repo (any) should be self-contained to the degree where it should be possible for any contributor to...
From this point any contributor — humans and agentic AIs alike — should be able to use all features of the development environment. Expect all of the following features to work flawlessly:
🛠️ D.I.Y — Resources
If you are an experienced developer, you probably don't want long detailed install instructions, so let's start with the bare essentials:
VS Code
brew install --cask visual-studio-codewinget install Microsoft.VisualStudioCodesudo snap install code --classicDocker Engine
Important
On windows, the Docker engine must be setup to use WSL (as opposed to Hyper-V)
Headless - No GUI
You do not need a GUI like Podman/Docker Desktop/Orbstack.
(On windows you run the Debian command in your Ubuntu Terminal - you don't even install docker in the Windows system).
brew install docker colima1sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin2Docker Desktop
brew install --cask dockerwinget install Docker.DockerDesktopsudo apt install ./docker-desktop-[ARCH].deb3Podman
brew install podman-desktopwinget install RedHat.PodmanDesktopsudo apt install podman4Orbstack (Mac only)
brew install orbstackInstall the VS Code MCP servers and Extensions
Install GitHub MCP server*
@mcp, click "Enable MCP servers marketplace"Or simply run...
code --add-mcp '{"name":"io.github.github/github-mcp-server","type":"http","url":"https://githubcopilot.com","gallery":"https://api.mcp.github.com","version":"0.30.3"}'Find and install (or just verify) the following extensions.
Or simply run...
👆IF YOU ARE COOL with the D.I.Y. approach👆
You can now run the final test to verify that you are done!
👀 HOW TO DO THIS ON WINDOWS
It's our observation that (sometimes) Windows users aren't always confident in Linux and the setup process is also a bit more complicated, because WSL (Windows Subsystem for Linux) is required to be installed first. So we have provided a detailed setup guide – specifically for Windows users.
Here's the task list:
userandpasswdnameandemail.profileIn Windows
STEP 1: Install on Windows (use PowerShell)
Using
winget(the built in CLI for package installs), the installation process is very straightforward. You can run these commands in a standard PowerShell terminal (or run as Admin). If you do not run as admin Windows may prompt you for permission during the install.(You can also copy the commands one by one and run then individually)
Important
before you run the next steps.
This is required for the WSL and Docker features to fully register in the Windows kernel.
In Ubuntu
After the install we need to install and configure more stuff in Ubuntu
Open the "Ubuntu 24.04" app from your Start menu.
The following commands must all be run from the Ubuntu teminal.
Step 2: Set Ubuntu
userandpasswdFirst time it will be prompted to create:
Step 3: Install WSL utilities
Note
WSLU
An open-source collection of command-line utilities designed to seamlessly bridge the gap between a Linux environment and your host Windows system.
Ubuntu in WSL is headless and out-of-the-box it doesn't know how to start a browser from the terminal. We need that. So we will install
wsluStep 4: Initialize git
user.nameanduser.emailmust be set, or Git will refuse to run.Tip
Set name to your full name, and the email to one that is registered with your GitHub account
e.g.
GITNAME="Lars Kruse" & GITEMAIL="lakruzz@mindovermachine.dk"The run
Step 5: Setup GitHub CLI
We also want to be able to use the GitHub Cli.
Caution
To install the GitHub CLI (gh) on Ubuntu,
sudo apt install ghis valid, BUT it is best to use the official GitHub repository rather than the default Ubuntu one. The version in the standard Ubuntu "apt" library is often outdated, which can cause issues with authentication.At time of this writing (July 2026) the standard ubuntu source will give you
ghin version 2.45.0 and the second will give you version 2.97.2.Use GitHub CLI's own repository:
Step 6: Setup GitHub authentication
First you will authenticate against GitHub and then store the token in you Ubuntu profile, this profile is read be each docker container that starts so effectively your Docker containers will inherit the GitHub authentication from the host.
To authenticate run:
Tip
The one-time code is already copied to the clipboard, so just press enter, paste the clipboard into the browser, accept the app, close the browser again.
Note
The
ghcli looks for authentication in the following places in the following order, and stops with the first it finds:$GH_TOKENEnvironment variable$GITHUB_TOKENEnvironment variable~/.config/gh/hosts.ymlStep 7: Store the GitHub CLI token as a variable in your
.profileThe way you just authenticated, Your token is now stored in your
/.config/gh/hosts.ymlso it's persisted between logins. But for easier integration with Dev containers we will rather pass on a Environment variables to the container than mount host files. So next we will store the token in an environment variable:If you run
gh auth statusyou will see that you now have both.exit)gh auth statusto see that both auth sources settings are now persisted.👉 Optimize Docker Integration 👈 (no need to go here unless you experience problems)
Open Docker Desktop on Windows.
Go to Settings (⚙ icon).
> Resources > WSL Integration Ensure "Enable integration with my default WSL distro" is enabled.
> Resources > Advanced If you find that Docker is slow to wake up when you run your first command, you can experiment with disable "Resource Saver"
> General Make sure "Use containerd for pulling and storing images" is checked. It allows for faster image pulls and better support for multi-platform builds.
The
.wslconfigfileWSL can sometimes try to "eat" all your RAM. You can cap its appetite by creating a configuration file in Windows.
notepad "$env:USERPROFILE\.wslconfig"Paste this in (adjusting memory to about 50% of your total RAM):
Save and restart WSL by running
wsl --shutdownin PowerShell.Done!
🧪 The final test
Let's clone a simple, open source repo, that uses dev containers and see if we can make it work:
Docker will now build the container.
When the container is up and running
default.code-workspaceand ask if you want to work in that code space — Choose that optionThe repo you have opened is the source for (model.mindovemachine.dk)[https://model.mindovemachine.dk] you can build it locally and run the dev server.
Footnotes
Start the engine in the terminal with
colima start↩Make sure WSL supports
systemd; in/etc/wsl.confbe sure to addsystemd=truein the[boot]section. ↩This command is and abstraction. Installing Docker Desktop on Ubuntu requires manually downloading the .deb package for your architecture first. Alternatively, on Linux, you probably can do without the graphical UI shell, use
sudo apt install docker-ceto get Docker Community Edition (CE) - it's quite sufficient (even recommended) for our purpose. ↩Using
apt install podmanhandles the core engine installation on Linux. Graphical user interface installs generally leverage Flatpak viaflatpak install flathub io.podman_desktop.PodmanDesktop↩All reactions