Skip to content

Commit c1c5bdf

Browse files
author
Greg Van Liew
authored
Merge pull request #5587 from microsoft/bamurtaugh/dev-container-aug
Update dev containers content
2 parents bc27bb1 + 0762798 commit c1c5bdf

File tree

5 files changed

+131
-194
lines changed

5 files changed

+131
-194
lines changed

docs/remote/containers.md

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ This quick start covers how to set up a dev container for an existing project to
105105

106106
The list will be automatically sorted based on the contents of the folder you open.
107107

108-
You may be able to customize your dev container with additional features, which [you can read more about below](#dev-container-features-preview).
108+
You may be able to customize your dev container with additional Features, which [you can read more about below](#dev-container-features-preview).
109109

110110
The dev container definitions displayed come from the [vscode-dev-containers repository](https://aka.ms/vscode-dev-containers). You can browse the `containers` folder of that repository to see the contents of each definition.
111111

@@ -260,45 +260,58 @@ Selecting the **Remote-Containers: Add Development Container Configuration Files
260260

261261
To learn more about creating `devcontainer.json` files, see [Create a Development Container](/docs/remote/create-dev-container.md).
262262

263-
## Dev container features (preview)
263+
## Dev Container Features (preview)
264264

265-
Dev container features provide a smooth path for customizing your container definitions.
265+
Development container "Features" are self-contained, shareable units of installation code and dev container configuration. The name comes from the idea that referencing one of them allows you to quickly and easily add more tooling, runtime, or library "Features" into your development container for you or your collaborators to use.
266266

267267
When you use **Remote-Containers: Add Development Container Configuration Files**, you're presented a list of scripts to customize the existing dev container configurations, such as installing Git or the Azure CLI:
268268

269-
![Dev container features in Command Palette](images/containers/container-features.png)
269+
![Dev container Features in Command Palette](images/containers/container-features.png)
270270

271-
When you rebuild and reopen in your container, the features you selected will be available in your `devcontainer.json`:
271+
When you rebuild and reopen in your container, the Features you selected will be available in your `devcontainer.json`:
272272

273273
```json
274274
"features": {
275-
"github-cli": "latest"
275+
"ghcr.io/devcontainers/features/github-cli:1": {
276+
"version": "latest"
277+
}
276278
}
277279
```
278280

279281
You'll get IntelliSense when editing the `"features"` property in the `devcontainer.json` directly:
280282

281-
![Intellisense when modifying terraform feature](images/containers/features-intellisense.png)
283+
![Intellisense when modifying terraform Feature](images/containers/features-intellisense.png)
282284

283-
Built-in features are sourced from the [script library](https://github.com/microsoft/vscode-dev-containers/tree/main/script-library/docs) folder in the vscode-dev-containers repo, but the Remote - Containers extension and GitHub Codespaces include an **early preview** for creating your own dev container features. For example, you can reference these as follows:
285+
The **Remote-Containers: Configure Container Features** command allows you to update an existing configuration.
284286

285-
```json
286-
"features": {
287-
"your-github-id-or-org/your-repository/[email protected]": "latest"
288-
}
287+
The Features sourced in VS Code UI come from the [`devcontainers/features` repository](https://github.com/devcontainers/features).
288+
289+
### Creating your own feature
290+
291+
It's also easy to create and publish your own Dev Container Features. Published Features can be stored and shared as [OCI Artifacts](https://github.com/opencontainers/artifacts) from any supporting public or private container registry. You can see the list of current published Features on [containers.dev](https://containers.dev/features.html).
292+
293+
A Feature is a self contained entity in a folder with at least a `devcontainer-feature.json` and `install.sh` entrypoint script:
294+
295+
```
296+
+-- feature
297+
| +-- devcontainer-feature.json
298+
| +-- install.sh
299+
| +-- (other files)
289300
```
290301

291-
The form and format of these custom features is still in flux, but you can try creating your own dev container feature using the [dev-container-features-template](https://github.com/microsoft/dev-container-features-template) sample repository. Let us know what you think!
302+
See the [latest template](https://github.com/devcontainers/feature-template) for instructions on using the dev container CLI to publish your own public or private Features!
292303

293-
The **Remote-Containers: Configure Container Features** command allows you to update an existing configuration.
304+
### Features proposal and distribution
305+
306+
Features are an active proposal in the open dev container specification. You can review the [Features proposal](https://github.com/devcontainers/spec/issues/61), along with [greater information about how Features work](https://containers.dev/implementors/features/) and their [distribution](https://containers.dev/implementors/features-distribution/).
294307

295308
## Pre-building dev container images
296309

297310
We recommend pre-building images with the tools you need rather than creating and building a container image each time you open your project in a dev container. Using pre-built images will result in a faster container startup, simpler configuration, and allows you to pin to a specific version of tools to improve supply-chain security and avoid potential breaks. You can automate pre-building your image by scheduling the build using a DevOps or continuous integration (CI) service like GitHub Actions.
298311

299-
We recommend using the [devcontainer CLI](/docs/remote/devcontainer-cli.md) to pre-build your images since it is kept in sync with the Remote - Container extension's latest capabilities - including [dev container features](#dev-container-features-preview). Once you've built your image, you can push it to a container registry (like the [Azure Container Registry](https://docs.microsoft.com/azure/container-registry/container-registry-get-started-docker-cli?tabs=azure-cli), [GitHub Container Registry](https://docs.github.com/packages/working-with-a-github-packages-registry/working-with-the-container-registry#pushing-container-images), or [Docker Hub](https://docs.docker.com/engine/reference/commandline/push)) and reference it directly.
312+
We recommend using the [devcontainer CLI](/docs/remote/devcontainer-cli.md) to pre-build your images since it is kept in sync with the Remote - Container extension's latest capabilities - including [dev container Features](#dev-container-features-preview). Once you've built your image, you can push it to a container registry (like the [Azure Container Registry](https://docs.microsoft.com/azure/container-registry/container-registry-get-started-docker-cli?tabs=azure-cli), [GitHub Container Registry](https://docs.github.com/packages/working-with-a-github-packages-registry/working-with-the-container-registry#pushing-container-images), or [Docker Hub](https://docs.docker.com/engine/reference/commandline/push)) and reference it directly.
300313

301-
See the [devcontainer CLI article on pre-building images](/docs/remote/devcontainer-cli.md#building-a-dev-container-image) for more information.
314+
See the [devcontainer CLI article on pre-building images](/docs/remote/devcontainer-cli.md#pre-building) for more information.
302315

303316
## Inspecting volumes
304317

@@ -695,6 +708,12 @@ The following articles may help answer your question:
695708
* [Docker Desktop for Mac troubleshooting guide](https://docs.docker.com/docker-for-mac/troubleshoot) and [FAQ](https://docs.docker.com/docker-for-mac/faqs/)
696709
* [Docker Support Resources](https://success.docker.com/article/best-support-resources)
697710

711+
### Can I use dev containers outside of VS Code?
712+
713+
As containerizing production workloads becomes commonplace, dev containers have become broadly useful for scenarios beyond VS Code. We're creating the **Development Containers Specification** to empower anyone in any tool to configure a consistent dev environment. It seeks to find ways to enrich existing formats with common development specific settings, tools, and configuration while still providing a simplified, un-orchestrated single container option – so that they can be used as coding environments or for continuous integration and testing.
714+
715+
You can learn more and review the spec on [containers.dev](https://containers.dev), and you can review active proposals and contribute to the spec in the [devcontainers/spec](https://github.com/devcontainers/spec) repository on GitHub.
716+
698717
## Questions or feedback
699718

700719
* See [Tips and Tricks](/docs/remote/troubleshooting.md#container-tips) or the [FAQ](/docs/remote/faq.md).
@@ -710,4 +729,4 @@ The following articles may help answer your question:
710729
* [Attach to a Running Container](/docs/remote/attach-container.md) - Attach to an already running Docker container.
711730
* [Create a Development Container](/docs/remote/create-dev-container.md) - Create a custom container for your work environment.
712731
* [Advanced Containers](/remote/advancedcontainers/overview.md) - Find solutions to advanced container scenarios.
713-
* [devcontainer.json reference](/docs/remote/devcontainerjson-reference.md) - Review the `devcontainer.json` schema.
732+
* [devcontainer.json reference](https://containers.dev/implementors/json_reference/) - Review the `devcontainer.json` schema.

docs/remote/create-dev-container.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,4 +489,4 @@ The path used for looking up the configuration is derived from the output of `gi
489489

490490
* [Attach to a Running Container](/docs/remote/attach-container.md) - Attach to an already running Docker container.
491491
* [Advanced Containers](/remote/advancedcontainers/overview.md) - Find solutions to advanced container scenarios.
492-
* [devcontainer.json reference](/docs/remote/devcontainerjson-reference.md) - Review the `devcontainer.json` schema.
492+
* [devcontainer.json reference](https://containers.dev/implementors/json_reference/) - Review the `devcontainer.json` schema.

docs/remote/devcontainer-cli.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,76 @@ These steps above are also provided in the CLI repo's [README](https://github.co
126126

127127
If you'd like to use the dev container CLI in your CI/CD builds or test automation, you can find examples of GitHub Actions and Azure DevOps Tasks in the [devcontainers/ci](https://github.com/devcontainers/ci) repository.
128128

129+
## Pre-building
130+
131+
The `devcontainer build` command allows you to build quickly build dev container image following the same steps the Remote - Containers extension or GitHub Codespaces will. This is particularly useful when you want to pre-build a dev container image using a CI or DevOps product like GitHub Actions.
132+
133+
`build` accepts a path to the folder containing a `.devcontainer` folder or `.devcontainer.json` file. For example, `devcontainer build --workspace-folder <my_repo>` will build the container image for `my_repo`.
134+
135+
### Example of building and publishing an image
136+
137+
For example, you may want to pre-build a number of images that you then reuse across multiple projects or repositories. To do so, follow these steps:
138+
139+
1. [Create](/docs/editor/versioncontrol.md#initialize-a-repository) a source code repository.
140+
141+
1. Create dev container configuration for each image you want to pre-build, customizing as you wish (including [dev container Features](#dev-container-features-preview)). For example, consider this devcontainer.json file:
142+
143+
```json
144+
{
145+
"build": {
146+
"dockerfile": "Dockerfile"
147+
},
148+
"features": {
149+
"ghcr.io/devcontainers/features/docker-in-docker:1": {
150+
"version": "latest"
151+
}
152+
}
153+
}
154+
```
155+
156+
1. Use the `devcontainer build` command to build the image and [push](https://docs.docker.com/engine/reference/commandline/push/) it to your image registry. See documentation for your image registry (like the [Azure Container Registry](https://docs.microsoft.com/azure/container-registry/container-registry-get-started-docker-cli?tabs=azure-cli), [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#pushing-container-images), or [Docker Hub](https://docs.docker.com/engine/reference/commandline/push)) for information on image naming and additional steps like authentication.
157+
158+
```bash
159+
devcontainer build --workspace-folder <my_repo> --push true --image-name <my_image_name>:<optional_image_version>
160+
```
161+
162+
1. Create a simplified devcontainer.json in repositories where you'd like to use the image - the devcontainer.json should either use the `image` property or reference the image in an associated Docker Compose file. Include any dev container Features you added in your pre-build configuration. For example:
163+
164+
```json
165+
{
166+
"image": "ghcr.io/your-org/your-image-name",
167+
"features": {
168+
"ghcr.io/devcontainers/features/docker-in-docker:1": {
169+
"version": "latest"
170+
}
171+
}
172+
}
173+
```
174+
175+
On the other hand, if you only intend to use the pre-built image from one repository, you can use the `cacheFrom` property in devcontainer.json or `cache_from` in a related Docker Compose file instead. This will download the image and treat its image layers like a local cache even if this is the first time you've created the Dockerfile on your machine. Like the option above, be sure to include any dev container Features. For example:
176+
177+
```json
178+
{
179+
"build": {
180+
"dockerfile": "Dockerfile",
181+
"cacheFrom": "ghcr.io/your-org/your-image-name"
182+
},
183+
"features": {
184+
"ghcr.io/devcontainers/features/docker-in-docker:1": {}
185+
}
186+
}
187+
188+
## Avoiding problems with images built using Docker
189+
190+
Given Dockerfiles and Docker Compose files can be used without VS Code or the `devcontainer` CLI, you may want to let users know that they should not try to build the image directly. You may learn more in the [advanced dev container documentation](../../remote/advancedcontainers/reduce-docker-warnings.md#avoiding-problems-with-images-built-using-docker).
191+
129192
## Feedback
130193

131194
The dev container CLI and specification are under active development and we welcome your feedback, which you can provide in [this issue](https://github.com/devcontainers/cli/issues/7), or through new issues and pull requests in the [devcontainers/cli](https://github.com/devcontainers/cli) repository.
132195

133196
## Next steps
134197

135198
* [Dev container specification repository](https://github.com/devcontainers/spec) - Read and contribute to the open specification.
136-
* [devcontainer.json reference](/docs/remote/devcontainerjson-reference.md) - Review the `devcontainer.json` schema.
199+
* [devcontainer.json reference](https://containers.dev/implementors/json_reference/) - Review the `devcontainer.json` schema.
137200
* [Create a Development Container](/docs/remote/create-dev-container.md) - Create a custom container for your work environment.
138201
* [Advanced Containers](/remote/advancedcontainers/overview.md) - Find solutions to advanced container scenarios.

0 commit comments

Comments
 (0)