What is Devcontainer?

Devcontainer is an open specification for enriching containers with development-specific content and settings. VSCode and Github Codespaces currently have full support for it. You can find the official documentation here. It's a great way to ensure consistency across different environments and to make sure that your development environment is isolated from your host machine. It's also a great way to ensure that your development environment is reproducible.

With devcontainer, you can easily share your development environment with your team, and you can also use it to develop on the go - using Github Codespaces or your remote docker context running on a Cloud VM, a Raspberry Pi, or your local machine (even if you don't have a public IP, more on that later)

A Quick Dive

Let's first have a quick look at what a devcontainer is - by creating one. We'll create a simple devcontainer with Ubuntu. We'll use the official vscode devcontainer tutorial as a reference.

Prerequisites

Steps

What just happened?

VSCode created a docker container with Ubuntu and mounted the current directory as a volume inside the container. It also installed some vscode extensions inside the container.

Now, as you have a terminal inside the container, you can run any command inside the container. You can also install any package inside the container. But remember, the container is ephemeral. If you exit the container, and reopen it, you'll have to install the packages again.

For a more persistent solution, you can create a Dockerfile inside the .devcontainer folder as described here. You can also use a docker-compose.yml file to create a multi-container devcontainer as described here

What's a Feature?