DEV Community

Cover image for Tidy up your machine with Visual Studio Code Dev Containers
Giorgio Boa for This is Learning

Posted on • Updated on


Tidy up your machine with Visual Studio Code Dev Containers

I recently discovered the Visual Studio Code - Dev Containers feature and I thought to share with you it because in my opinion, it's so cool.

I'm collaborating on an open source project in Rust and as soon as I approached the repo I thought:
"No, I don't want to install all the dependencies and mess up my environment with a thousand things..."

Developer Experience

Fortunately, the project maintainers were smart enough to configure the project to be able to contribute without much fuss.

Visual Studio Code Dev Containers

The Visual Studio Code Dev Containers extension lets you use a Docker container as a full-featured development environment. It allows you to open any folder or repository inside a container and take advantage of Visual Studio Code's full feature set.




describes how VS Code should start the container and what to do after it connects.

// For format details, see
  "name": "My devcontainer",
  "hostRequirements": {
    "cpus": 4
  // Add the IDs of extensions you want installed when the container is created.
  "extensions": [
  "build": {
    "dockerfile": "Dockerfile"
  "waitFor": "onCreateCommand",
  "updateContentCommand": "corepack prepare & pnpm install",
  "forwardPorts": [3300, 9229],
  "customizations": {
    "codespaces": {
      "openFiles": [""]
  "portsAttributes": {
    "3300": {
      "label": "Serve",
      "onAutoForward": "openPreview"
Enter fullscreen mode Exit fullscreen mode


We can use a Dockerfile that defines the contents of the container.

FROM cimg/rust:1.65.0-node

RUN rustup --version; \
    cargo --version; \
    rustc --version; \
    rustup update; \
    rustup target add wasm32-unknown-unknown; \
    cargo install cargo-insta; \
    rustup component add clippy; \
    corepack enable --install-directory ~/bin
Enter fullscreen mode Exit fullscreen mode


Obviously, you need to have Docker up and running on your machine.

VsCode Extension



To spin up the container and work inside it, you need to install the Dev Containers extension and then you can run
Dev Containers: Open Folder in Container command.

Ready to go


So far so good, after the startup, you're ready to develop inside the docker container with a fully configured environment.

You can follow me on Twitter, where I'm posting or retweeting interesting articles.

I hope you enjoyed this article, don't forget to give ❤️.
Bye 👋

Latest comments (7)

jobinnelson profile image
Jobin-Nelson • Edited

Which open source project are you working on ? I would like to start contributing to open source as well. My interest is with rust

gioboa profile image
Giorgio Boa

I'm contributing to Qwik because is a friendly community and I found a lot of smart devs 👏😉

hoangnhvt profile image

Thanks. Can you write a tut for coding by dev container on Github codespaces

gioboa profile image
Giorgio Boa

Here I created an article to show how cool are GitHub Codespaces. ☺️

shawncrigger profile image
Shawn Crigger

Thanks the only problem is Docker charges a ridiculous fee for windows now. I’ve been using WSL2 and about to attempt to make a company wsl so everyone has the same install, directories, user, etc due to upgrading a app that requires PHP 8 MySQL 8 and a lot of other dependencies from the version we have already

yukikimoto profile image
Yuki Kimoto - SPVM - Perl Club


hmphu profile image
Phu Hoang

Great article, thanks for sharing this.

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.