title | shortTitle | intro | allowTitleToDifferFromFilename | versions | type | topics | redirect_from | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Adding features to a devcontainer.json file |
Adding features |
With features, you can quickly add tools, runtimes, or libraries to your dev container configuration. |
true |
|
how_to |
|
|
{% data reusables.codespaces.about-features %} Use the tabs in this article to display instructions for each of these ways of adding features.
{% webui %}
-
Navigate to your repository on {% data variables.product.prodname_dotcom_the_website %}, find your
devcontainer.json
file, and click {% octicon "pencil" aria-label="Edit this file" %} to edit the file.If you don't already have a
devcontainer.json
file, you can create one now. For more information, see "AUTOTITLE." -
To the right of the file editor, in the Marketplace tab, browse or search for the feature you want to add, then click the name of the feature.
-
Under "Installation," click the code snippet to copy it to your clipboard, then paste the snippet into the
features
object in yourdevcontainer.json
file."features": { ... "ghcr.io/devcontainers/features/terraform:1": {}, ... }
-
By default, the latest version of the feature will be used. To choose a different version, or configure other options for the feature, expand the properties listed under "Options" to view the available values, then add the options by manually editing the object in your
devcontainer.json
file."features": { ... "ghcr.io/devcontainers/features/terraform:1": { "version": "1.1", "tflint": "latest" }, ... }
-
Commit the changes to your
devcontainer.json
file.
The configuration changes will take effect in new codespaces created from the repository. To make the changes take effect in existing codespaces, you will need to pull the updates to the devcontainer.json
file into your codespace, then rebuild the container for the codespace. For more information, see "AUTOTITLE."
{% endwebui %}
{% vscode %}
{% note %}
To add features in {% data variables.product.prodname_vscode_shortname %} while you are working locally, and not connected to a codespace, you must have the "Dev Containers" extension installed and enabled. For more information about this extension, see the {% data variables.product.prodname_vs_marketplace_shortname %}.
{% endnote %}
{% data reusables.codespaces.command-palette %}
-
Start typing "add dev" then click Codespaces: Add Dev Container Configuration Files.
-
Click Modify your active configuration.
-
Update your feature selections, then click OK.
-
If you're working in a codespace, a prompt will appear in the lower-right corner. To rebuild the container and apply the changes to the codespace you're working in, click Rebuild Now.
{% endvscode %}