Re-visiting Dev Container Features

Paul Yu - Dec 2 '22 - - Dev Community

A few months ago I wrote a post that described how you can add custom features to your Dev Containers. That didn't age very well 😅

But good news is that there is a better way to add or extend functionality for your Dev Containers. 🥳

Since my original post, @BrigitMurtaugh published a post on the VS Code blog announcing new repos, the open dev container specification and discussed a new way of adding features. If you haven't read the post, go check it out here.

Additionally, a community member submitted feedback in the new devcontainers/features repo suggesting that Azure CLI extensions should just be supported as part of the azure-cli feature. And so, I was happy to contribute the Azure CLI extension installation code that I wrote about previously to this new azure-cli feature.

What's new with the azure-cli feature

The new feature can be added by referencing the package URL: ghcr.io/devcontainers/features/azure-cli:1.0.7.

Dev Container Features are published as GitHub packages

It accepts two new options: extensions and installBicep.

The extensions option expects a comma-separated list of Azure CLI extension names. Make sure you have the extension name spelled correctly here. If you misspelled an extension name, the azure-cli feature installation code will skip over it and continue installing other extensions in the list. You will see output in the container build logs stating the misspelled extension wasn't found, but it's easy to miss if you aren't paying attention to the logs.

The installBicep option expects a boolean value (true or false). When set to true, Azure Bicep will be installed and will be made available to you using either the az bicep command or the standalone bicep command.

Here is an example of what your devcontainer.json file would look like if you needed Azure CLI with Azure Bicep and the Azure Managed Grafana, AKS (preview), and Azure Container Apps extensions installed:

{
  "name": "Ubuntu",
  "image": "mcr.microsoft.com/devcontainers/base:jammy",
  "features": {
    "ghcr.io/devcontainer/features/azure-cli:1.0.7": {
      "version": "latest",
      "extensions": "amg,aks-preview,containerapp",
      "installBicep": true
    }
  },
  "remoteUser": "vscode"
}
Enter fullscreen mode Exit fullscreen mode

More Dev Container features

The list of available features is impressive and includes features that are maintained by the Dev Container Spec Maintainers team as well as features that are maintained by folks in the community. So if there's a feature for your Dev Container that you'd like to share, please feel free to contribute to the public repo.

The cool thing here is that even if you don't contribute a feature to the public repo, you can always create a feature using the new feature-starter template and host it in your own GitHub repo. The template includes a GitHub Action workflow file that will publish the feature for you. If you'd like to share your self-hosted feature with a broader audience, fork the containers.dev site repo, edit the collection-index.yml file, and issue a Pull Request to have your feature appear in the available features list.

I highly encourage you all to provide feedback and/or contribute features to make Dev Containers awesome for everyone!

As always, hit me up on Twitter or in the comments below if you have any questions ✌️

Happy packaging!

Resources

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player