Linux command
devcontainer 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Build a dev container
devcontainer build --workspace-folder [.]
Start a dev container
devcontainer up --workspace-folder [.]
Execute command in
devcontainer exec --workspace-folder [.] [command]
Open shell in
devcontainer exec --workspace-folder [.] bash
Read configuration
devcontainer read-configuration --workspace-folder [.]
List features
devcontainer features list
Generate templates
devcontainer templates apply -t [python]
Show resolved configuration as JSON
devcontainer read-configuration --workspace-folder [.] --include-merged-configuration
说明
devcontainer is the CLI for managing development containers defined by the Dev Container specification. It allows building, running, and interacting with containerized development environments from the command line. Dev containers provide reproducible development environments using Docker containers. Configuration in .devcontainer/devcontainer.json defines the container image, extensions, settings, and features needed for a project. The CLI enables dev container workflows without IDE integration, useful for CI/CD pipelines, remote development, and automation of development environment setup.
参数
- --workspace-folder _PATH_
- Path to workspace with .devcontainer config.
- build
- Build the dev container image.
- up
- Create and start the container.
- exec _COMMAND_
- Run command in container.
- read-configuration
- Output resolved configuration.
- features list
- List available dev container features.
- templates apply -t _template_
- Apply a dev container template to the workspace.
- run-user-commands
- Run user commands (postCreateCommand, etc.) in the container.
- --help
- Display help information.
- --version
- Display version information.
FAQ
What is the devcontainer command used for?
devcontainer is the CLI for managing development containers defined by the Dev Container specification. It allows building, running, and interacting with containerized development environments from the command line. Dev containers provide reproducible development environments using Docker containers. Configuration in .devcontainer/devcontainer.json defines the container image, extensions, settings, and features needed for a project. The CLI enables dev container workflows without IDE integration, useful for CI/CD pipelines, remote development, and automation of development environment setup.
How do I run a basic devcontainer example?
Run `devcontainer build --workspace-folder [.]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --workspace-folder _PATH_ do in devcontainer?
Path to workspace with .devcontainer config.