Visual Studio Code Development Containers
I’ve been using Visual Studio Dev Containers to have a seamless development experience across different operating systems. The way Visual Studio Dev Container works is by leveraging Docker’s containerization functionality to allow using Visual Studio Code inside the container. The result is that your VS Code application looks and functions as if you were actually running whichever Linux image you built. In order to use Visual Studio Code Dev Containers, you must have Docker installed on your operating system. Afterwards, you’d create a file (devcontainer.json
) which tells VS Code how to access a dev container. Here is an example:
```json
{
"image": "mcr.microsoft.com/devcontainers/typescript-node",
"forwardPorts": [3000],
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["streetsidesoftware.code-spell-checker"]
}
}
}
```
Credit mcr.microsoft.com/devcontainers
is Microsoft’s container registry for dev containers mcr.microsoft.com/devcontainers/typescript-node
is a Docker image that describes a pre-configured environment for Node.js & TypeScript tools – you can develop in that language immediately forwardPorts
tells VS Code to forward port 3000 from container to host machine which is useful for web servers or apps running inside the container customizations
enables you to customize the environment (install additional packages, etc)
There’s more to learn about each of the fields in the documentation (like having multiple ports, the variety of customization parameters, etc) but this is a general summary of what Dev Containers are.