Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

cli

> 编程语言
Open source

A reference implementation for the specification that can create and configure a dev container from a devcontainer.json.

46.2K stars0 likes1 views
WebsiteGitHub

About

A reference implementation for the specification that can create and configure a dev container from a devcontainer.json.

Dev Container CLI

This repository holds the dev container CLI, which can take a devcontainer.json and create and configure a dev container from it.

Context

A development container allows you to use a container as a full-featured development environment. It can be used to run an application, to separate tools, libraries, or runtimes needed for working with a codebase, and to aid in continuous integration and testing. Dev containers can be run locally or remotely, in a private or public cloud.

This CLI is in active development. Current status:

  • devcontainer build - Enables building/pre-building images
  • devcontainer up - Spins up containers with devcontainer.json settings applied
  • devcontainer run-user-commands - Runs lifecycle commands like postCreateCommand
  • devcontainer read-configuration - Outputs current configuration for workspace
  • devcontainer exec - Executes a command in a container with userEnvProbe, remoteUser, remoteEnv, and other properties applied
  • devcontainer outdated - Show outdated lockfile features
  • devcontainer upgrade - Upgrade lockfile features
  • devcontainer features <...> - Tools to assist in authoring and testing Dev Container Features
  • devcontainer templates <...> - Tools to assist in authoring and testing Dev Container Templates
  • devcontainer stop - Stops containers
  • devcontainer down - Stops and deletes containers

Lockfiles (.devcontainer-lock.json) are generated by default when running build or up to pin feature versions for reproducible builds. Use --no-lockfile to opt out, or --frozen-lockfile to enforce an existing lockfile.

Try it out

We'd love for you to try out the dev container CLI and let us know what you think. You can quickly try it out in just a few simple steps, either by using the install script, installing its npm package, or building the CLI repo from sources (see "Build from sources").

Install script

You can install the CLI with a standalone script that downloads a bundled Node.js runtime, so no pre-installed Node.js is required. It works on Linux and macOS (x64 and arm64):

curl -fsSL https://raw.githubusercontent.com/devcontainers/cli/main/scripts/install.sh | sh

Then add the install location to your PATH:

export PATH="$HOME/.devcontainers/bin:$PATH"

You can also specify a version, a custom install directory, or update/uninstall an existing installation:

# Install a specific version
sh install.sh --version 0.82.0

# Install to a custom directory
sh install.sh --prefix ~/.local/devcontainers

# Update to latest
sh install.sh --update

# Uninstall
sh install.sh --uninstall

npm install

To install the npm package you will need Python and C/C++ installed to build one of the dependencies (see, e.g., here for instructions).

npm install -g @devcontainers/cli

Verify you can run the CLI and see its help text:

…

Try out the CLI

Once you have the CLI, you can try it out with a sample project, like this Rust sample.

Clone the Rust sample to your machine, and start a dev container with the CLI's up command:

git clone https://github.com/microsoft/vscode-remote-try-rust
devcontainer up --workspace-folder <path-to-vscode-remote-try-rust>

This will download the container image from a container registry and start the container. Your Rust container should now be running:

…

You can then run commands in this dev container:

devcontainer exec --workspace-folder <path-to-vscode-remote-try-rust> cargo run

This will compile and run the Rust sample, outputting:

[33 ms] dev-containers-cli 0.1.0.
   Compiling hello_remote_world v0.1.0 (/workspaces/vscode-remote-try-rust)
    Finished dev [unoptimized + debuginfo] target(s) in 1.06s
     Running `target/debug/hello_remote_world`
Hello, VS Code Remote - Containers!
{"outcome":"success"}

Congrats, you've just run the dev container CLI and seen it in action!

More CLI examples

The example-usage folder contains some simple shell scripts to illustrate how the CLI can be used to:

  • Inject tools for use inside a development container
  • Use a dev container as your CI build environment to build an application (even if it is not deployed as a container)
  • Build a container image from a devcontainer.json file that includes dev container features

Build from sources

This repository has a dev container configuration, which you can use to ensure you have the right dependencies installed.

Compile the CLI with yarn:

yarn
yarn compile

Verify you can run the CLI and see its help text:

node devcontainer.js --help

Specification

The dev container CLI is part of the Development Containers Specification. This spec seeks to find ways to enrich existing formats with common development specific settings, tools, and configuration while still providing a simplified, un-orchestrated single container option – so that they can be used as coding environments or for continuous integration and testing.

Learn more on the dev container spec website.

Additional resources

You may review other resources part of the specification in the devcontainers GitHub organization.

Documentation

  • Additional information on using the built-in Features testing command.

Contributing

Check out how to contribute to the CLI in CONTRIBUTING.md.

License

This project is under an MIT license.

GitHub Issues· 310 open

View all on GitHub
  • #1122

    Unactionable error while publishing to private gitlab registry

    Updated Sep 14, 2026
  • #1284

    Podman fix: derive `--userns=keep-id` mapping from the remote user's actual UID/GID

    Updated Sep 11, 2026
  • #1236

    Podman: up can hang after "Container started" on create/recreate

    Updated Sep 9, 2026
  • #1301

    Podman: automatic `--userns=keep-id` breaks containers using host networking

    Updated Sep 3, 2026
  • #1231

    Dockerfile `ENV` mutates system-wide `/etc/environment`

    Updated Sep 3, 2026
  • #1300

    Podman: --userns=keep-id and --security-opt label=disable are never applied on the Docker Compose path

    Updated Sep 2, 2026
  • #1286

    Multi-variable ARG declared via line continuation loses its second variable

    Updated Sep 1, 2026
  • #1298

    Feature request: First-class array input for Feature options (array option type + multiple invocations) [blocked on spec#766]

    Updated Aug 28, 2026

Highlights

  • •[x] devcontainer build - Enables building/pre-building images
  • •[x] devcontainer up - Spins up containers with devcontainer.json settings applied
  • •[x] devcontainer run-user-commands - Runs lifecycle commands like postCreateCommand
  • •[x] devcontainer read-configuration - Outputs current configuration for workspace
  • •[x] devcontainer exec - Executes a command in a container with userEnvProbe, remoteUser, remoteEnv, and other properties applied
  • •[x] devcontainer outdated - Show outdated lockfile features
  • •[x] devcontainer upgrade - Upgrade lockfile features
  • •[x] devcontainer features <...> - Tools to assist in authoring and testing Dev Container Features
  • •[x] devcontainer templates <...> - Tools to assist in authoring and testing Dev Container Templates
  • •[ ] devcontainer stop - Stops containers

> Tags

TypeScriptcontainersdevcontainers

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言