Introduction to Development Container

A Simple Way to Reproduce Your Environment

Wednesday, the 8th of October, 2025

About Me

  • I am Mickaël CANOUIL, I hold a Ph.D. in Biostatistics, with over a decade of academic experience in the genetics of type 2 diabetes and obesity.
  • My research has contributed to understanding the genetic and molecular mechanisms underlying metabolic diseases, with publications in leading journals.
  • Currently, I work as a consultant in biostatistics, applying my expertise to diverse projects in multi-omics and data analysis.
  • I am also deeply involved in the Quarto ecosystem, developing extensions and tools that enhance reproducibility and scientific communication.
  • My contributions, including Quarto Wizard and various Quarto extensions, aim to streamline workflows for researchers and data scientists.
  • You can explore my work on GitHub, my projects, and my publications.

Introduction to Dev Containers

What Are Dev Containers?

  • Dev Containers allow developers to work inside a predefined, isolated environment.

  • By leveraging Docker, they provide a consistent and repeatable setup, removing “it works on my machine” issues.

  • They integrate seamlessly with Visual Studio Code and GitHub Codespaces, enabling developers to code, build, and debug inside the container while using their familiar tools.

Why Use Dev Containers?

  • Developers often face challenges in maintaining consistency across various systems.

  • Imagine working with a Python project that requires specific dependencies. One developer may have version conflicts, another may struggle with installation.

  • Dev Containers solve this by ensuring each team member uses the exact same environment, reducing debugging time and improving workflow efficiency.

Understanding Dev Containers

How Dev Containers Work

Rather than installing dependencies manually, developers define their development environment inside a .devcontainer directory in their Git repository.

.devcontainer
└── devcontainer.json

This configuration directory instructs Docker to create a workspace that includes all necessary tools and settings.

How Dev Containers Work

A typical workflow:

  1. Developer opens a project in Visual Studio Code.
  2. VS Code detects the presence of a .devcontainer configuration.
  3. The container is built and launched, ready for coding.

A notification from a Visual Studio Code indicates that the folder contains a Dev Container configuration file. The message suggests reopening the folder to develop in a container and provides a link to learn more. There are two buttons: "Reopen in Container" in green and "Don't Show Again..." in gray. The source of the notification is the "Dev Containers" extension.

Prerequisites

Before diving into Dev Containers, ensure:

Setting Up
Dev Containers

Creating a Dev Container

Let’s get started! To create a Dev Container, follow these steps:

  1. Open your project in VS Code.
  2. Use the Command Palette and search for “Dev Containers: Add Dev Container Configuration Files…”.
  3. Choose an appropriate template for your stack (Node.js, Python, Rust, etc.).
  4. Your project now contains a .devcontainer/devcontainer.json file.

Editing this file allows further customisation.

Example devcontainer.json

Consider a simple Quarto CLI setup:

{
  "name": "My Dev Container",
  "image": "ghcr.io/mcanouil/quarto-codespaces:latest",
  "remoteUser": "vscode",
  "customizations": {
    "vscode": {
      "extensions": [
        "quarto.quarto",
        "mcanouil.quarto-wizard"
      ]
    }
  }
}
1
The Docker image is specified in the image field. It’s built using a Dev Container specification that you can find in .github/.devcontainer.
2
The quarto extension for Visual Studio Code / Positron to provide support for Quarto documents.
3
The quarto-wizard extension for Visual Studio Code / Positron to provide assistance in managing Quarto extensions

Customising Your Environment

A basic setup may be sufficient, but advanced users often refine their environment:

{
  "name": "My Dev Container",
  "image": "ghcr.io/mcanouil/quarto-codespaces:latest",
  "remoteUser": "vscode",
  "features": {
    "ghcr.io/devcontainers/features/docker-in-docker:2": {},
    "ghcr.io/devcontainers/features/github-cli:1": {}
  },
  "customizations": {
    "settings": {
      "r.rterm.option": [ "--no-save", "--no-restore-data", "--quiet"]
    },
    "vscode": {
      "extensions": ["quarto.quarto", "mcanouil.quarto-wizard"]
    }
  }
}
1
Features: This section allows you to add pre-defined features to your container, such as Docker-in-Docker or the GitHub CLI.
2
Settings: Custom Visual Studio Code settings can be defined here, such as R options.

Building and Running
the Dev Container

Visual Studio Code

Once the configuration is set, building and running the container is straightforward:

  1. Open the Command Palette and select “Dev Containers: Reopen in Container”.
  2. VS Code will build the container based on the configuration.
  3. Once built, the container will launch, and you can start coding.

GitHub Codespaces

For those using GitHub Codespaces, the process is similar:

  1. Open your repository on GitHub.
  2. Click on the green “Code” button and select “Open with Codespaces”.
  3. GitHub will automatically build the Dev Container based on the configuration.
  4. Once the Codespace is ready, you can start coding directly in the browser.

The Dev Container CLI

For advanced users, the Dev Container CLI provides additional flexibility. With simple commands, developers can build, start, and interact with their containers from the terminal.

  1. Install the CLI globally using npm:

    npm install -g @devcontainers/cli
  1. Use the CLI to build and run your Dev Container:

    devcontainer build --workspace-folder .
    devcontainer up --id-label name=my-container --workspace-folder .
    devcontainer exec --id-label name=my-container pwd

Live Demonstration

Conclusion

Use Cases and Benefits

Picture a developer moving between machines or working remotely. Instead of reinstalling dependencies, they simply open their project inside a pre-configured Dev Container.

Other advantages:

  • Remote Development: Work on code from any system.
  • Team Collaboration: Share a unified development environment.
  • Sandboxing: Experiment with dependencies without risking the host machine.
  • CI/CD Integration: Ensure build reproducibility.

Summary

Dev Containers provide a structured, reliable development environment that simplifies onboarding and improves collaboration.
Whether working solo or in a team, adopting containerised development ensures that everyone works inside the same, pre-configured setup.

With Dev Containers, development becomes more predictable and efficient. Embrace the change today!

Further Resources

About