Skip to content

Commit edc5ba1

Browse files
committed
sandboxes: document sbx secret set --registry for private OCI pulls
Cover the new --registry flag on sbx secret set / rm: how to store host-only, global (sandbox-injected), and sandbox-scoped registry credentials, and how they differ from proxy-injected service secrets. Replace the "private templates/kits only on Docker Hub" callouts in customize/templates.md and customize/kits.md with the stored-credential flow, and note that sbx kit push still requires docker login.
1 parent 069012f commit edc5ba1

3 files changed

Lines changed: 114 additions & 15 deletions

File tree

content/manuals/ai/sandboxes/customize/kits.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,17 @@ For Docker Hub, include the full `docker.io` prefix. See
366366
[Packaging and distribution](#packaging-and-distribution) for publishing.
367367

368368
> [!IMPORTANT]
369-
> Private kits are only supported on Docker Hub. `sbx` reuses your
370-
> `sbx login` session to pull private artifacts from Docker Hub. Other
371-
> registries are pulled anonymously, so private kits hosted on
372-
> registries other than Docker Hub fail to pull.
369+
> For Docker Hub, `sbx` reuses your `sbx login` session to pull private
370+
> kits. For other registries, store pull credentials with
371+
> [`sbx secret set --registry`](../security/credentials.md#registry-credentials)
372+
> before running the sandbox:
373+
>
374+
> ```console
375+
> $ gh auth token | sbx secret set --registry ghcr.io --password-stdin
376+
> ```
377+
>
378+
> Without stored credentials, pulls from non-Docker Hub registries are
379+
> anonymous and private kits fail to pull.
373380

374381
## Packaging and distribution
375382

@@ -389,6 +396,12 @@ The `sbx kit` subcommands validate, inspect, and publish kits:
389396
For Docker Hub, include the full `docker.io` prefix — `sbx` doesn't add it
390397
automatically.
391398

399+
`sbx kit pull` prefers credentials stored with
400+
[`sbx secret set --registry`](../security/credentials.md#registry-credentials),
401+
falling back to the Docker credential store. `sbx kit push` only uses the
402+
Docker credential store, so pushing to a private registry requires a prior
403+
`docker login`.
404+
392405
## Spec reference
393406

394407
A kit directory has a required `spec.yaml` and an optional `files/` tree:

content/manuals/ai/sandboxes/customize/templates.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,21 @@ $ docker build -t my-org/my-template:v1 --push .
118118
> daemon on the host.
119119
120120
> [!IMPORTANT]
121-
> Private templates are only supported on Docker Hub. `sbx` reuses your
122-
> `sbx login` session to pull private images from Docker Hub. Other
123-
> registries (such as GitHub Container Registry, ECR, or a self-hosted
124-
> registry like Nexus) are pulled anonymously, so private images on those
125-
> registries fail to pull.
126-
127-
For locally-built images or private images on registries that `sbx`
128-
can't authenticate against, save the image to a tar and load it
129-
directly into the sandbox runtime instead of pulling from a registry:
121+
> For Docker Hub, `sbx` reuses your `sbx login` session to pull private
122+
> images. For other registries (GitHub Container Registry, ECR, ACR, a
123+
> self-hosted Nexus, and so on), store pull credentials with
124+
> [`sbx secret set --registry`](../security/credentials.md#registry-credentials)
125+
> before running the sandbox:
126+
>
127+
> ```console
128+
> $ gh auth token | sbx secret set --registry ghcr.io --password-stdin
129+
> ```
130+
>
131+
> Without stored credentials, pulls from non-Docker Hub registries are
132+
> anonymous and private images fail to pull.
133+
134+
For locally-built images, save the image to a tar and load it directly
135+
into the sandbox runtime instead of pulling from a registry:
130136
131137
```console
132138
$ docker image save my-org/my-template:v1 -o my-template.tar

content/manuals/ai/sandboxes/security/credentials.md

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ There are two host-side stores, plus a host shell fallback:
4646
and visible to other processes running as your user. See
4747
[Environment variables](#environment-variables).
4848

49+
Registry credentials are a separate store with a different purpose. They
50+
authenticate the `sbx` CLI (and optionally the sandbox itself) to private
51+
OCI registries for template and kit pulls, and are not used by the
52+
credential-injection proxy. See [Registry credentials](#registry-credentials).
53+
4954
If both a stored secret and a host environment variable are set for the same
5055
service, the stored secret takes precedence. For multi-provider agents
5156
(OpenCode, Docker Agent), the proxy selects credentials based on the API
@@ -127,8 +132,8 @@ List all stored secrets:
127132

128133
```console
129134
$ sbx secret ls
130-
SCOPE SERVICE SECRET
131-
(global) github gho_GCaw4o****...****43qy
135+
SCOPE TYPE NAME SECRET
136+
(global) service github gho_GCaw4o****...****43qy
132137
```
133138

134139
Remove a secret:
@@ -203,6 +208,81 @@ proxy replaces it with the real value. The agent never sees the real secret.
203208
Prefer the [service-based flow](#stored-secrets) whenever it's an option —
204209
the kit handles the wiring; you only provide the value.
205210

211+
## Registry credentials
212+
213+
Registry credentials authenticate to private OCI registries when pulling
214+
[templates](../customize/templates.md) or [kits](../customize/kits.md). Use
215+
`sbx secret set --registry <host>` to store them. They are independent from
216+
service secrets: the proxy doesn't touch them, and they're used directly by
217+
the `sbx` CLI when resolving image references.
218+
219+
For Docker Hub, `sbx` reuses your `sbx login` session — no registry secret
220+
needed. For other registries (GitHub Container Registry, ECR, ACR,
221+
self-hosted Nexus, and so on), store credentials with `sbx secret set
222+
--registry`.
223+
224+
### Store registry credentials
225+
226+
Pipe a token from stdin and target the registry hostname:
227+
228+
```console
229+
$ gh auth token | sbx secret set --registry ghcr.io --password-stdin
230+
```
231+
232+
For registries that require a username (for example, ACR with an admin
233+
account), add `--username`:
234+
235+
```console
236+
$ echo "$ACR_PASSWORD" | sbx secret set \
237+
--registry myregistry.azurecr.io \
238+
--username myuser \
239+
--password-stdin
240+
```
241+
242+
Three scopes control where the credential is used:
243+
244+
- Host-only (no `-g`, no sandbox name): the `sbx` CLI uses it to pull
245+
templates and kits when creating a sandbox. The credential is not
246+
injected into the sandbox itself, so processes inside the sandbox can't
247+
use it.
248+
- Global (`-g`): same as host-only, plus written into `~/.docker/config.json`
249+
in every new sandbox. Use this when agents need to pull or push from
250+
inside the sandbox — for example, when an agent builds and publishes
251+
container images.
252+
- Sandbox-scoped (positional `SANDBOX` argument): credential applies only
253+
to that named sandbox. Useful when only one sandbox needs access to a
254+
private registry.
255+
256+
```console
257+
$ gh auth token | sbx secret set -g --registry ghcr.io --password-stdin
258+
$ gh auth token | sbx secret set my-sandbox --registry ghcr.io --password-stdin
259+
```
260+
261+
`sbx kit pull` also uses these credentials, with the Docker credential
262+
store as a fallback. `sbx kit push` uses only the Docker credential store —
263+
push targets still require a prior `docker login`.
264+
265+
### Remove registry credentials
266+
267+
Remove both the host-only and global entries for a registry:
268+
269+
```console
270+
$ sbx secret rm --registry ghcr.io -f
271+
```
272+
273+
To remove only the global (sandbox-injected) entry and leave the
274+
host-only credential in place, pass `-g`:
275+
276+
```console
277+
$ sbx secret rm -g --registry ghcr.io -f
278+
```
279+
280+
To remove a sandbox-scoped credential, pass the sandbox name:
281+
282+
```console
283+
$ sbx secret rm my-sandbox --registry ghcr.io -f
284+
```
285+
206286
## Environment variables
207287

208288
As an alternative to stored secrets, export the relevant environment variable

0 commit comments

Comments
 (0)