Skip to content

Using dev containers in VSCode on Windows without using Docker Desktop

Why do I need this? - Using Docker Desktop for commercial use requires a license!

Docker Desktop is only free for small businesses with fewer than 250 employees AND less than $10 million in annual revenue. Docker Subscription Service Agreement

What are dev containers?

Dev Containers in Visual Studio Code are Docker containers used as full-featured development environments. They allow opening any folder inside a container, leveraging VS Code’s features. The contents of the dev container can be defined using a devcontainer.json file.

Create a development container using Visual Studio Code Remote Development

Why use dev containers?

  • Consistent Development Environments: Dev Containers provide a consistent, isolated, and reproducible development environment.
  • Quick Setup: Dev Containers allow for quick setup of new projects. Simply clone the repository and open the workspace in VS Code that has a .devcontainer/devcontainer.json file.
  • Project Isolation: Each project has its own isolated dev environment, preventing version conflicts and avoiding polluting your system with development dependencies.
  • Improved Collaboration: Dev Containers have improved project collaboration between developers by addressing inconsistent local developer experiences within a team.
  • Efficient Onboarding: Dev Containers can significantly speed up the onboarding process for developers joining a project. No more setup of your local dev environment.
  • Seamless Switching: You can seamlessly switch your entire development environment just by connecting to a different container.
  • Customizability: The development environment can be customized as per project requirements, including adding VS Code extensions, installing additional tools, or defining commands to automatically run when the container starts.
  • Keep your local machine clean: No need to install all VSCode extensions and dependencies on your local machine.

How do I get it to work without Docker Desktop on Windows using wsl2:

There are a bunch of options for your wsl install which can be found here - Install WSL | Microsoft Learn

The steps below should get you going:

1. In powershell 7 terminal (Windows terminal):

wsl --install

2. Open ubuntu terminal from windows terminal using the drop down arrow at the top

sudo apt update && sudo apt install docker.io
sudo apt update && sudo apt install docker-compose
sudo groupadd docker
sudo usermod -aG docker $USER

3. VSCode settings

  • Option Dev > Containers: Docker Compose Path (dev.containers.dockerComposePath): set to /usr/bin/docker-compose
  • Option Dev > Containers: Docker Path (dev.containers.dockerPath): set to /usr/bin/docker
  • Option Dev > Containers: Execute in WSL (dev.containers.executeInWSL): Check this box
  • Option Dev > Containers: Execute in WSLDistro (dev.containers.executeInWSLDistro) will only be needed if you have multiple WSL distributions installed

4. Create a project in vscode with a .devcontainer/devcontainer.json file and select "Reopen in Container" from the Remote Window icon bottom left