devcontainer

Subscribe to all “devcontainer” posts via RSS or follow GitHub Changelog on Twitter to stay updated on everything we ship.

~ cd github-changelog
~/github-changelog|main git log main
showing all changes successfully

Adding a configuration for Codespaces involves adding a Development Container to a repository and editing it to meet your needs. Previously, a dev container configuration could either be written manually or created with a VS Code extension. We have now added the ability to create or edit a configuration directly from the Code drop down on a GitHub repository page.

Code dropdown showing the new Codespaces configuration option

Whether you use this mechanism, or you already have a dev container in your repository, you can now edit that configuration within GitHub using the new configuration editor. To open the editor from the code view in a repository, click the pencil icon while viewing a devcontainer.json file.

screenshot of view of devcontainer.json file

You are now editing the devcontainer.json file in place in the browser. The dev container needs to conform to the Development Container specification. The editor makes using dev container Features easy. Dev container Features provide reusable configurations for Codespaces created from the repository. Browse available features from right side of the dev container editor.

screenshot of editor and marketplace

To use a dev container feature, copy the snippet of json and place it in the features object of your devcontainer.json file. Once you have the features you want, commit those changes to the repository by clicking the "Start commit" button.

screenshot of the start commit button function

We hope this will make configuring your repositories for Codespaces significantly easier.

See more

When you are building out a configuration for Codespaces using a dev container, the default behavior is now to do an incremental rebuild. The existing rebuild functionality is still available and has been renamed to ‘Full rebuild’.

Incremental rebuild is much faster because it builds on top of your existing docker cache, reusing common images and layers between rebuilds. This is readily apparent when adding configurations to the default container for Codespaces which is quite large.

When using VS Code, you access these commands from the command palette.

Rebuild commands in the command palette in Visual Studio Code!

The rebuild behavior prior to this change was full rebuild, which is slower but guarantees correctness because it removes all images from the virtual machine before re-pulling even unchanged images. You may occasionally want to do this after many iterations of rebuilding your configuration, and want to free up disk space or ensure your configuration is not dependent on layers that won’t be present during a clean creation of a codespace from the configuration.

See more