NOTE: Most of the contents of this repository have been migrated to the new devcontainers GitHub org (https://github.com/devcontainers). See https://github.com/devcontainers/template-starter and https://github.com/devcontainers/feature-starter for information on creating your own!
Перейти к файлу
Chuck Lantz bdf8d9d629 Update README.md 2019-03-28 11:11:49 -07:00
.github/ISSUE_TEMPLATE Update bug_report.md 2019-03-28 09:48:44 -07:00
.vscode Fixes 2019-03-28 09:30:42 -07:00
container-templates Another restructure rev 2019-03-27 12:22:15 -07:00
containers Markdown, repo dev container, issue templates 2019-03-28 09:27:15 -07:00
.gitignore Update .gitignore 2019-03-27 12:27:18 -07:00
CONTRIBUTING.md Update CONTRIBUTING.md 2019-03-27 20:32:34 -07:00
LICENSE Initial commit 2018-11-05 04:52:41 -08:00
README.md Update README.md 2019-03-28 11:11:49 -07:00

README.md

Visual Studio Code Remote Development Container Definitions

A development container is a running Docker container that comes with a basic tool stack (Python, node, Go, etc.) and its prerequisites (e.g. pylint for Python). This container may be used to actually run an application or be focused exclusively on sandboxing tools, libraries, runtimes, or other utilities that need to be run against a codebase.

Visual Studio Code Remote allows you to open any folder inside (or mounted into) a dev container and take advantage of VS Code's full feature set. When using the capability, VS Code selectively runs certain extensions in the container to optimize your experience. The result is that VS Code can provide a local-quality development experience including full IntelliSense, debugging, and more regardless of where your code is hosted.

See here to learn more about VS Code Remote.

This repository contains a set of dev container definitions made up of files like devContainer.json to help get you up and running in a containerized environment. These definitions describe the needed container image, any runtime arguments for starting the container, and any VS Code extensions that should be installed into it.

Trying a definition

  1. Click on one of the containers sub-folders to open it in your browser
  2. Check out the README to see if there are any manual steps
  3. Clone this repository or copy the contents of the folder to your machine
  4. Run the Remote: Open Folder in Container... command in VS Code
  5. Select the definition folder in the "open" dialog

Many definitions include a test-project that you can use to see the dev container in action. Note that if you open this folder locally instead, you'll be prompted to reopen it in a container as well. You can also use the Remote: Reopen Folder in Container command at any time.

Using a definition

You can either:

  • Run Remote: Create Container Configuration File... command in VS Code and pick a definition. The appropriate files will then be added to your project.

  • Manually copy the contents of one of the containers sub-folders into your project. Copy the .devcontainer folder and .vscode/devContainer.json into your project and you should be ready to go!

Can I just reuse an existing Docker configuration?

Absolutely! If you want to use an existing Dockerfile as a starting point, run Remote-Docker: Create Container Configuraton File... from the command pallette (Cmd/Ctrl+Shift+P). You'll be prompted to select a Dockerfile or you can opt to use a base image instead.

About .vscode/devContainer.json

The intent of devContainer.json is conceptually similar to VS Code's launch.json for debugging, but designed to launch (or attach to) your development container instead. At its simplest, all you need to do is add a .vscode/devContainer.json file to your project and reference an image, Dockerfile, or docker-compose.yml.

Since you are here, check out the Existing Dockerfile and Existing Docker Compose definitions for details, but here's the a quick tour of the basic properties. If you have a Dockerfile, set these properties:

{
    "name": "[Optional] Your project name here",
    "dockerFile": "Dockerfile"
}

Similarly, if you have a docker-compose.yml file, set these properties:

{
    "name": "[Optional] Your project name here",
    "dockerComposeFile": "docker-compose.yml",
    "service": "the-name-of-the-service-you-want-to-work-with-in-vscode",
    "volume": "/container/path/to/source/code"
}

The other definitions in the containers folder will provide examples of how to cover new scenarios you may encounter along the way. For example, you may want to alter your configuration to install additional tools like Git in the container, automatically install extensions, expose additional ports, or set runtime arguments. In other cases, you may just want to attach to an already running container.

Adding a definition to an existing public or private repo

You can easily share a customized dev container definition for your project by simply adding files like .vscode/devContainer.json to source control. By including these files in your repository, anyone that opens a local copy of your repo in VS Code will be automatically asked if they want reopen the folder in a container instead if the Remote Development extension installed.

You can also have VS Code prompt anyone opening your repo to install the Remote Development extension. Simply add the extension ID to recommendations array in .vscode/extensions.json (as described here) and then add the file to source control.

{
    "recommendations": [
        "vscode.remotedevelopment"
    ]
}

Beyond the advantages of having your team use a consistent environment and tool-chain, doing this can make it easier for new contributors or team members to get productive quickly. First-time contributors will require less guidance and are less likely to either submit issues or contribute code with issues that are related to environment setup.

Contents

  • containers - Dev container definition folders.
  • container-templates - Templates for creating your own container definitions in your project or for contributing back to this repository.

Contributing & Feedback

Have a question or feedback? There are many ways to contribute.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

License

Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See LICENSE.