Bitzu

GH-900 ยท Automation and AI-assisted development

Dev containers and devcontainer.json

devcontainer.json configuration to define tools, extensions and settings for a reproducible Codespace or local container.

Key points

  • A dev container configuration, usually .devcontainer/devcontainer.json, describes the development environment for a repository: a base image or a Dockerfile build, extra tools and runtimes (features), VS Code settings and extensions.
  • Committed to the repo, it makes every Codespace (or local container) reproducible.
  • Without one, Codespaces uses a default Linux image with common languages and tools.

Source: https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers

Practice questions

Single choice

What is the default location of the dev container configuration file?

  1. .github/workflows/devcontainer.json
  2. .devcontainer/devcontainer.json
  3. docs/devcontainer.json
  4. .codespaces/config.yml
Show answer

Answer: B. .devcontainer/devcontainer.json

.devcontainer/devcontainer.json is the default. A .devcontainer.json at the repository root also works, but the other paths are not used.

Select all that apply

What can a dev container configuration define?

  1. The base image or a Dockerfile to build from
  2. Extra tools and runtimes via features
  3. VS Code settings for the environment
  4. The organization's Copilot billing plan
  5. Who is allowed to merge pull requests
Show answer

Answer: A. The base image or a Dockerfile to build from, B. Extra tools and runtimes via features, C. VS Code settings for the environment

It can set the base image or Dockerfile build, add tools through features, and apply VS Code settings. It does not define your billing plan or who may merge pull requests.

True or false

True or false: a repository without any dev container configuration cannot be opened in a codespace.

Show answer

Answer: False

False. Without a configuration, Codespaces falls back to a default Linux image that includes common languages and tools such as Git and the GitHub CLI.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More GH-900 topics in this module