For the complete documentation index, see llms.txt. A markdown version of this page is at /guides/run-devcontainer/index.md.

Run a repository's devcontainer

Build a repository's own devcontainer.json on a workstation, open your shell inside the container, and rebuild or repair it later.

Build a repository’s own devcontainer.json on a workstation, open your shell inside the container, and rebuild or repair it later. Use it when your team already maintains a devcontainer and you don’t want to rewrite it as a Ringleader configuration.

Prerequisites

  • Install Ringleader, with the Ringleader application running.
  • A repository with a devcontainer.json that your workstation can clone. For a private repository, see SSH keys for outbound Git and Code sources.
  • To repair a failed build, the SSH configuration that Connect to a workstation with SSH adds.
  • The examples use a workstation named app-box in the local namespace, which the first task creates, and a repository at git@github.com:acme/app.git. Replace them with your own.

Run the devcontainer

You declare the repository as a code source of a new workstation and turn on its devcontainer. The workstation then clones the code, builds the container and puts your shell inside it.

  1. Create a file called app-box.yaml that declares the repository under spec.sources:

    apiVersion: workstations.ringleader.dev/v1
    kind: Workstation
    metadata:
      name: app-box
      namespace: local
    spec:
      sources:
        - name: app
          path: /workspaces/app
          git:
            url: git@github.com:acme/app.git
          devcontainer:
            enabled: true
  2. Optional: If the file isn’t at .devcontainer/devcontainer.json or .devcontainer.json, add configPath under devcontainer, relative to the source’s path.

  3. In the same file, add a size under spec:

    spec:
      providerConfig:
        cpus: 4
        memory: 8   # GiB
        disk: 100   # GiB

    Workstation size for a devcontainer says how to choose these values.

  4. Apply the file:

    rl apply -f app-box.yaml
  5. Wait until the container is built. The first build takes minutes:

    rl workstation wait app-box -n local --for condition=Configured=True --timeout 30m
  6. Open a shell:

    rl shell app-box -n local

    You are now inside the container, as the file’s remoteUser.

Devcontainer declaration says what the declaration adds to the workstation, and Devcontainer readiness says when the workstation counts as ready.

Rebuild the devcontainer

After you change devcontainer.json, build the container again on the workstation. A change doesn’t rebuild it by itself, as Changes to devcontainer.json explains.

  1. On your computer, restart the devcontainer service on the workstation’s virtual machine, with --host:

    rl shell app-box -n local --host -- sudo systemctl restart devcontainer
  2. Open a new shell with rl shell app-box -n local. It lands in the rebuilt container.

Run a command on the virtual machine

Your shell lands in the container. To run one command on the workstation’s virtual machine instead, add --host:

rl shell app-box -n local --host -- uptime

rl file cp --host copies to and from the virtual machine the same way. Devcontainer shell and file locations lists where each tool lands.

Repair a failed build

A devcontainer that fails to build keeps the workstation from reaching Configured, but the <user>-host login still works. These steps fix the file and bring the workstation back to Configured. Devcontainer readiness says why.

  1. On your computer, read what failed:

    rl troubleshoot app-box -n local --failed

    The report shows the failing step and its output.

  2. Log in to the virtual machine as the host user, which is your workstation’s login user followed by -host. This example uses the login user dev:

    ssh dev-host@app-box
  3. On the virtual machine, edit the file the report names, such as /workspaces/app/.devcontainer/devcontainer.json.

  4. Close the SSH session to return to your computer.

  5. Build the container again with the command in Rebuild the devcontainer.

  6. Wait for Ringleader to try the failed step again:

    rl workstation wait app-box -n local --for condition=Configured=True --timeout 10m

    The command returns once the workstation is Configured. Retries after a failed step says how the retries are timed.

Next steps