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.jsonthat 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-boxin thelocalnamespace, which the first task creates, and a repository atgit@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.
Create a file called
app-box.yamlthat declares the repository underspec.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: trueOptional: If the file isn’t at
.devcontainer/devcontainer.jsonor.devcontainer.json, addconfigPathunderdevcontainer, relative to the source’spath.In the same file, add a size under
spec:spec: providerConfig: cpus: 4 memory: 8 # GiB disk: 100 # GiBWorkstation size for a devcontainer says how to choose these values.
Apply the file:
rl apply -f app-box.yamlWait until the container is built. The first build takes minutes:
rl workstation wait app-box -n local --for condition=Configured=True --timeout 30mOpen a shell:
rl shell app-box -n localYou 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.
On your computer, restart the
devcontainerservice on the workstation’s virtual machine, with--host:rl shell app-box -n local --host -- sudo systemctl restart devcontainerOpen 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 -- uptimerl 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.
On your computer, read what failed:
rl troubleshoot app-box -n local --failedThe report shows the failing step and its output.
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 userdev:ssh dev-host@app-boxOn the virtual machine, edit the file the report names, such as
/workspaces/app/.devcontainer/devcontainer.json.Close the SSH session to return to your computer.
Build the container again with the command in Rebuild the devcontainer.
Wait for Ringleader to try the failed step again:
rl workstation wait app-box -n local --for condition=Configured=True --timeout 10mThe command returns once the workstation is
Configured. Retries after a failed step says how the retries are timed.
Next steps
- Devcontainer workstations says
which
devcontainer.jsonsettings work, and when the workstation counts as ready. - Port and socket forwarding forwards a container’s published port to your computer, as a LocalBinding.
- Shells and remote commands runs commands, scripts and persistent sessions on a workstation.