Feature request: `@devcontainers/cli` as a docker CLI plugin

Open
#827 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
docker, shell, typescript
Domain
cli, devops

Research direction

Start by reviewing the existing @devcontainers/cli command entry points and the Docker CLI plugin conventions referenced in the issue. Compare the requested docker devcontainer build and run forms with the current devcontainer up and exec commands, then read the linked pull requests and issue. Done requires an agreed plugin design, command mapping, and shell-completion scope.

Written by the indexing model from the issue text.

Description

feature-request

We've found it difficult to on-board users accustomed to the docker CLI to @devcontainers/cli.

It would be awesome if @devcontainers/cli were a docker CLI front-end plugin, similar to docker compose, docker buildx, etc.

Partially the motivation is similar to existing issues/PRs -- having a way to use the CLI without node would be great:

This would also hopefully provide incentive to better align with docker CLI idioms. For example:

  • The docker CLI has docker build, and Buildx/compose have docker buildx build and docker compose build.
  • The docker CLI has docker run, and compose has docker compose run.
  • etc.

For example, in the absence of devcontainer run <args>, we find ourselves writing scripts to wrap @devcontainers/cli and mimic the behavior:

local container_id rm up_args exec_args;

_parse_args_somehow rm up_args exec_args;

on_exit() {
    local code=$?;
    if test -n "${rm-}" && test -n "${container_id-}"; then
        docker rm -f "${container_id}" >/dev/null 2>&1 || true;
        container_id="";
    fi
    exit "${code}";
}

trap on_exit EXIT;

container_id="$(devcontainer up ${rm:+--remove-existing-container} "${up_args[@]}" | jq -r '.containerId')";

devcontainer exec --workspace-folder . --config <path> "${exec_args[@]}";

It would be really neat to type docker devcontainer build . or docker devcontainer run --rm -it ..., especially if the @devcontainers/cli plugin also shipped shell completions!

Dominant language
TypeScript
Stars
3k
Forks
461
Avg merge
18m
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from devcontainers/cli

All issues in devcontainers/cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.