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.
Practice questions
What is the default location of the dev container configuration file?
- .github/workflows/devcontainer.json
- .devcontainer/devcontainer.json
- docs/devcontainer.json
- .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.
What can a dev container configuration define?
- The base image or a Dockerfile to build from
- Extra tools and runtimes via features
- VS Code settings for the environment
- The organization's Copilot billing plan
- 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: 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.
