Join our Discord Server
Collabnix Team The Collabnix Team is a diverse collective of Docker, Kubernetes, and IoT experts united by a passion for cloud-native technologies. With backgrounds spanning across DevOps, platform engineering, cloud architecture, and container orchestration, our contributors bring together decades of combined experience from various industries and technical domains.

Debugging Docker Sandbox Kits: Progress Rows, Install Logs and the sbx -D Flag

6 min read

Dark terminal window showing the sbx -D create command and the title Debugging Docker Sandbox Kits

Kits are how you extend a Docker Sandbox. A kit can install a tool, copy files in, set environment variables, open network access, request a credential, and register commands that run every time the sandbox starts. When one of those steps fails, you need to know which command broke, in which kit, and where the full output is. Docker recently published a dedicated docs page, Debug a kit, that answers exactly that. This post walks through it in a hands-on way: how to read the progress rows that sbx prints, how to reproduce a failing install command outside the sandbox, where the full logs live, what the -D flag adds, what gets redacted, and how to fix the four failure patterns the docs call out.

Prerequisites

  • The sbx CLI installed and signed in. See the Docker Sandboxes get started guide if you are setting it up for the first time.
  • A kit you are writing or testing. Kits are an Early Access feature, and the debug page itself carries the Early Access label.
  • A version of Docker Sandboxes that supports the com.docker.sandbox/lifecycle@1 capability. The capability support table lists v0.45.0 as the first release for both local and cloud sandboxes.
  • Docker installed locally if you want to use the docker run reproduction hint described below.

Step 1: Give every command a description

During sbx create and sbx run, the “configure agent” phase prints one row per kit operation: install commands, init files, file copies, environment variables, and the startup commands that get registered. A finished row is marked with a check and the elapsed time, or with a cross and the exit code. Each command row also tells you the owning kit (kit=<name>) and the user the command ran as (user=<uid>).

The label on a row is the command’s description if the kit sets one. If it does not, you get the first 60 characters of the raw command, which for a long shell pipeline is often useless. So the first debugging habit is a preventive one: set a short description on every install and startup command. Only 60 characters of it are shown, so keep it tight.

Here is the example kit from the docs. It installs ripgrep as root during the install phase and records the ripgrep version on every container start:

# my-kit/my-kit.yaml
capabilities:
  - type: com.docker.sandbox/lifecycle@1
    config:
      install:
        - command: apt-get update && apt-get install -y ripgrep
          user: "0"
          description: Install ripgrep
      startup:
        - command: rg --version > /tmp/rg-version
          description: Record the ripgrep version

According to the docs, the rows for this kit look like this when everything works:

AGENT
running 1 install command
✓ Install ripgrep (kit=my-kit, user=0, 12.4s)
view install logs: ls /var/log/sbx-kits
registering 1 startup command, run on every container start
○ Record the ripgrep version (kit=my-kit, user=agent)
view startup log: cat /var/log/sbx-kit-startup.log

Two details are worth noticing. First, the install row shows user=0 because the kit asked for root, while the startup row runs as the agent user. Second, the output already tells you where to look next: the install logs directory and the startup log file. Those paths are the core of the rest of this post.

Step 2: Read a failed install command and reproduce it with docker run

When an install command fails, the row switches to a cross with the exit code, and sbx prints the last 40 lines of that command’s output directly under the row. The docs show this example of the same ripgrep kit failing:

✗ Install ripgrep (kit=my-kit, user=0, exit 100)
── captured output ──
E: Failed to fetch http://deb.debian.org/debian/dists/bookworm/InRelease 403 Forbidden
E: Unable to locate package ripgrep
──────────────────────
hint: reproduce locally with:
docker run --rm -u 0 <base-image> sh -c 'apt-get update && apt-get install -y ripgrep'

The last line is the most useful part. sbx gives you a ready made docker run command that runs the exact same command, as the same user, against the kit’s base image. Copy it, run it, change the command, and run it again. You get a tight edit and retry loop without recreating the sandbox each time. Once the command works, paste the fixed version back into the kit descriptor.

There is one important caveat. The reproduction runs in plain Docker, outside the sandbox, so the sandbox’s network policy does not apply to it. If a command succeeds under docker run but fails inside the sandbox, the likely difference is network access, and the docs say to check the kit’s network rules first. In the example above, the 403 Forbidden from the Debian mirror is exactly that kind of signal.

Step 3: Find the full logs inside the sandbox

The progress output only shows the tail of a failure. The sandbox keeps the full record in two places:

  • /var/log/sbx-kits/<kit>/install-<n>.log holds the full output of one install command. <n> is the position of the command in that kit’s install list, counting from 0.
  • /var/log/sbx-kit-startup.log holds the output of every startup command, from every container start.

Read them with sbx exec, which runs a command inside a sandbox and starts the sandbox first if it is stopped:

sbx exec my-sandbox cat /var/log/sbx-kits/my-kit/install-0.log
sbx exec my-sandbox cat /var/log/sbx-kit-startup.log

The startup log has a predictable structure. For every startup command it writes a > <script> line, a # <kit>: <description or command> line, the command’s output, and then ok <script> on success. A failing command ends with fail <script> exit=<code> instead of ok.

Failure handling for startup commands is different from install commands. A failing startup command stops the startup commands that come after it. The command that started the sandbox (sbx create, sbx run, sbx exec after sbx stop, or sbx kit add) prints a warning that points at the startup log and shows its last lines. The sandbox itself stays usable, so you can still exec into it and investigate.

Step 4: Turn on full output with -D

-D (long form --debug) is a global sbx option that enables debug logging. Pass it to sbx create or sbx run while you are developing a kit:

sbx -D create --name my-sandbox shell --kit ./my-kit

This creates a shell sandbox named my-sandbox and adds the local kit directory ./my-kit as a mixin through the experimental --kit flag. With -D, every successful install command also streams its full output under its row, not just failed ones, and sbx prints the startup log once the sandbox starts.

What sbx redacts from kit output

Everything a kit command prints passes through a single filter before it reaches your terminal. The filter strips terminal escape sequences and replaces known credential shapes with a placeholder such as <GITHUB_TOKEN>. The docs list GitHub, GitLab, OpenAI, Anthropic and AWS tokens, JSON Web Tokens, private keys, and Authorization headers as covered shapes.

Understand the limits of this filter before you rely on it:

  • It protects you from accidents, such as a command that dumps env or prints a config file with a key in it.
  • It is not a defence against output crafted to get around it.
  • It does not change a secret you wrote into the kit’s own command text. Do not put secrets in commands; use the credential capability instead.
  • The install log inside the sandbox keeps the raw, unfiltered output. Treat those log files as sensitive.

Fixing the four common failures

The install command cannot reach its package source

Symptoms: names that do not resolve, or HTTP 403 responses from the sandbox proxy, coming from apt, pip, or npm. Cause: the kit’s install phase network rules do not include the package mirror. Fix: add the mirror host to install.allow in the kit’s com.docker.sandbox/network-policy@1 capability. The docs warn that apt mirrors can live on a different host than the one the command names, so check the log for the host that actually failed. The install phase rules sit next to the runtime rules in the same capability. The runtime part below is taken from the docs’ Claude Code tool mixin example; replace the placeholder with the host from your log:

capabilities:
  - type: com.docker.sandbox/network-policy@1
    config:
      install:
        allow:
          - <package-mirror-host>:443
      runtime:
        allow:
          - api.anthropic.com:443

Two kits run apt at the same time

Symptom: Could not get lock /var/lib/dpkg/lock-frontend. Another install command, or the base image setup, holds the dpkg lock. Fix: make the package command in your kit wait and retry, for example by adding -o DPkg::Lock::Timeout=120 to the apt-get call.

A startup command needs a tool that did not install

Symptom: the startup log shows exec: <tool>: not found, and an earlier install command for that tool failed. Fix the install command first by reading its install-<n>.log, then rerun the sandbox. The startup failure is only a side effect.

The command needs root

Symptom: Permission denied when writing to a system path or installing a package, and the row shows user=1000. Fix: set user: "0" on the install command, as in the ripgrep example, or write to a location the agent user owns.

Local sandboxes vs Cloud Sandboxes

The debug workflow is written around local sandboxes: progress rows during sbx create and sbx run, logs read with sbx exec, and a docker run reproduction on your own machine. A few documented differences matter when the same kit goes to Docker Cloud Sandboxes:

  • lifecycle@1 is supported from v0.45.0 on both local and cloud sandboxes. The capability table notes that local startup hooks run alongside the agent rather than blocking its launch.
  • network-policy@1 has only limited support in the cloud: cloud sandboxes keep install phase network access after setup. So a mirror you add to install.allow can stay reachable after setup in a cloud sandbox.
  • Cloud sandboxes use cloud network policies; host network and HTTP policies do not apply. You can bake a mixin into a cloud sandbox with sbx --cloud create --name my-project shell --kit ./my-mixin/.
  • sbx exec also works against cloud sandboxes with --cloud, but some flags such as --user and --privileged are rejected there.

Troubleshooting tips

  • Works in docker run but not in the sandbox? Check the kit’s network rules before anything else.
  • One failing startup command hides the ones after it. Fix the first fail line in the startup log, then rerun.
  • For problems that are not kit specific, see the general sandbox troubleshooting page.

Key takeaways

  • Set a short description on every install and startup command; rows show at most 60 characters.
  • A failed install prints its last 40 lines plus a docker run line that reproduces it against the base image.
  • Full logs live in /var/log/sbx-kits/<kit>/install-<n>.log and /var/log/sbx-kit-startup.log. Read them with sbx exec.
  • sbx -D streams output for successful installs too and prints the startup log after start.
  • Output is redacted on the way to your terminal, but the in-sandbox install logs keep raw output.
  • Most failures are network rules, dpkg lock contention, a missing tool from a failed install, or a missing user: “0”.

References

Source guide: Debug a kit on Docker Docs. Related pages: Author kits, Kit authoring patterns, Build a tool mixin, Kit capability support, sbx exec reference, sbx create shell reference, and Docker Sandboxes troubleshooting.

Have Queries? Join https://launchpass.com/collabnix

Collabnix Team The Collabnix Team is a diverse collective of Docker, Kubernetes, and IoT experts united by a passion for cloud-native technologies. With backgrounds spanning across DevOps, platform engineering, cloud architecture, and container orchestration, our contributors bring together decades of combined experience from various industries and technical domains.

Understanding AI Embeddings and Vector Search for Beginners

Explore the world of AI embeddings and vector search, learning how they transform massive data into actionable insights, driving intelligent systems.
Collabnix Team
9 min read
Join our Discord Server