devcontainer
Develop projects in isolated, reproducible environments
TLDR
Create and run a Dev Container
Apply a Dev Container Template to a workspace
Execute a command on a running Dev Container in the current workspace
Build a Dev Container image from devcontainer.json
Open a Dev Container in VS Code (the path is optional)
Read and print the configuration of a Dev Container from devcontainer.json
SYNOPSIS
devcontainer [GLOBAL_OPTIONS] <COMMAND> [<ARGS>]
PARAMETERS
-w, --workspace-folder <DIR>
Path to workspace folder (default: current directory)
--config <PATH>
Path to devcontainer.json config file
--image-name <NAME>
Custom name for built image
--container-name <NAME>
Custom name for container
-n, --log-level <LEVEL>
Logging level: debug|info|warn|error (default: info)
--verbose
Enable verbose logging
--remove-on-stop
Remove container on stop
--env-file <PATH>
Load environment variables from file
--accept-defaults
Accept all prompts with defaults
-h, --help
Print help information
-v, --version
Print version
DESCRIPTION
The devcontainer command-line tool enables developers to build, run, and manage development containers defined via devcontainer.json configuration files. These containers provide reproducible, isolated development environments using Docker or compatible runtimes like Podman.
Key workflows include creating workspace-mounted containers (up), building custom images (build), executing commands (exec or run), stopping (stop or down), and viewing logs. It supports features like installing extensions, running tests, and using templates or features for quick setups.
Ideal for CI/CD, team onboarding, or local dev without VS Code GUI. Operates on workspace folders containing .devcontainer dirs, ensuring consistent tooling (languages, runtimes, extensions) across machines. Integrates with GitHub Codespaces and supports overrides for flexibility.
CAVEATS
Requires Docker/Podman and Node.js. Not installed by default; global install via npm. Subcommands like up, build have additional options shown via devcontainer <COMMAND> --help. Config must be in .devcontainer/devcontainer.json.
COMMON SUBCOMMANDS
up: Create/start container.
build: Build image.
exec: Run command in container.
down: Stop/delete.
INSTALLATION
npm install -g @devcontainers/cli
Or Docker: docker run -it --rm -v ${PWD}:/workdir mcr.microsoft.com/devcontainers/cli:0.XXX
HISTORY
Developed by Microsoft for VS Code Remote - Containers extension (2019). Standalone CLI (@devcontainers/cli) released 2022 via npm, supporting open Dev Container spec for cross-tool use.


