Developing inside a Container
AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. Join VS Code at Microsoft Ignite or catch the sessions online. A year of VS Code, wrapped. Explore the highlights. Developing inside a Container View as Markdown Ask in VS Code Ask in VS Code Insiders The Visual Studio Code Dev Containers extension lets you use a container as a full-featured development environment.
It allows you to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set. A devcontainer.json file in your project tells VS Code how to access (or create) a development container with a well-defined tool and runtime stack. This container can be used to run an application or to separate tools, libraries, or runtimes needed for working with a codebase. Workspace files are mounted from the local file system or copied or cloned into the container.
Extensions are installed and run inside the container, where they have full access to the tools, platform, and file system. This means that you can seamlessly switch your entire development environment just by connecting to a different container. This lets VS Code provide a local-quality development experience including full IntelliSense (completions), code navigation, and debugging regardless of where your tools (or code) are located .
The Dev Containers extension supports two primary operating models: You can use a container as your full-time development environment You can attach to a running container to inspect it. Note : The Dev Containers extension supports the open Dev Containers Specification, which empowers anyone in any tool to configure a consistent dev environment. You can learn more in our dev container FAQ and on the specification's site containers.dev .
Getting started Note : You can learn how to get up-and-running quickly with dev containers in the introductory Dev Containers tutorial . System requirements Local / Remote Host: You can use Docker with the Dev Containers extension in a few ways, including: Docker installed locally. Docker installed on a remote environment. Other Docker compliant CLIs, installed locally or remotely. While other CLIs may work, they are not officially supported.
Note that attaching to a Kubernetes cluster only requires a properly configured kubectl CLI . You can learn more in the alternative Docker options doc . Below are some specific ways you can configure Docker on a local or remote host: Windows: Docker Desktop 2.0+ on Windows 10 Pro/Enterprise. Windows 10 Home (2004+) requires Docker Desktop 2.3+ and the WSL 2 back-end . (Docker Toolbox is not supported. Windows container images are not supported.) macOS : Docker Desktop 2.0+.
Linux : Docker CE/EE 18.06+ and Docker Compose 1.21+. (The Ubuntu snap package is not supported.) Remote hosts: 1 GB RAM is required, but at least 2 GB RAM and a 2-core CPU is recommended. Containers : x86_64 / ARMv7l (AArch32) / ARMv8l (AArch64) Debian 9+, Ubuntu 16.04+, CentOS / RHEL 7+ x86_64 Alpine Linux 3.9+ Other glibc based Linux containers may work if they have needed Linux prerequisites . Installation To get started, follow these steps: Install and configure Docker for your operating system, using one of the paths below or an alternative Docker option , like Docker on a remote host or Docker compliant CLI.
Windows / macOS : Install Docker Desktop for Windows/Mac . If you are using WSL 2 on Windows, to ensure the WSL 2 back-end is enabled: Right-click on the Docker taskbar item and select Settings . Check Use the WSL 2 based engine and verify your distribution is enabled under Resources > WSL Integration . When not using the WSL 2 back-end, right-click on the Docker task bar item, select Settings and update Resources > File Sharing with any locations your source code is kept.
See tips and tricks for troubleshooting. Linux : Follow the official install instructions for Docker CE/EE for your distribution . If you are using Docker Compose, follow the Docker Compose directions as well. Add your user to the docker group by using a terminal to run: sudo usermod -aG docker $USER Sign out and back in again so your changes take effect. Install Visual Studio Code or Visual Studio Code Insiders . Install the Dev Containers extension .
If you plan to work with other remote extensions in VS Code, you may choose to install the Remote Development extension pack . Working with Git? Here are two tips to consider: If you are working with the same repository both locally in Windows and inside a container, be sure to set up consistent line endings. See tips and tricks for details. If you clone using a Git credential manager, your container should already have access to your credentials!
If you use SSH keys, you can also opt in to sharing them. See Sharing Git credentials with your container for details. Picking your quick start This document includes 3 quick starts - we recommend starting with the one that fits your workflow and interests the best: Want to try out a dev container in a quick sample repo? Check out Quick start 1: Try a development container . Want to add a dev container to one of your existing locally cloned projects?
Check out Quick start 2: Open an existing folder in a container . Want to work with an isolated copy of a repo, i.e. to review a PR or investigate a branch without impacting your local work? Check out Quick start 3: Open a git repo or PR in an isolated container volume . Quick start: Try a development container The easiest way to get started is to try one of the sample development containers. The Containers tutorial will walk you through setting up Docker and the Dev Containers extension and let you select a sample: Note: If you already have VS Code and Docker installed, then you may use open in dev container .
You can learn more about this and how to add it to your repos in the create a dev container guide . Quick start: Open an existing folder in a container This quick start covers how to set up a dev container for an existing project to use as your full-time development environment using existing source code on your filesystem. Follow these steps: Start VS Code, run the Dev Containers: Open Folder in Container... command from the Command Palette ( F1 ) or quick actions Status bar item, and select the project folder you would like to set up the container for.
Tip: If you want to edit the container's contents or settings before opening the folder, you can run Dev Containers: Add Dev Container Configuration Files... instead. Now pick a starting point for your dev container. You can either select a base Dev Container Template from a filterable list, or use an existing Dockerfile or Docker Compose file if one exists in the folder you selected. Note: When using Alpine Linux containers, some extensions may not work due to glibc dependencies in native code inside the extension.
The list will be automatically sorted based on the contents of the folder you open. You may be able to customize your dev container with additional Features, which you can read more about below . The dev container Templates displayed come from our first-party and community index , which is part of the Dev Container Specification . We host a set of Templates as part of the spec in the devcontainers/templates repository .
You can browse the src folder of that repository to see the contents of each Template. You can also choose to publish and distribute your own dev container Templates using the dev container CLI . After picking the starting point for your container, VS Code will add the dev container configuration files to your project ( .devcontainer/devcontainer.json ). The VS Code window will reload and start building the dev container.
A progress notification provides status updates. You only have to build a dev container the first time you open it; opening the folder after the first successful build will be much quicker. Aft
The rest of this page is on the live site.