Share feedback
Answers are generated based on the documentation.

sbx ports

内容説明Manage sandbox port publishing
利用方法sbx ports SANDBOX [flags]

Description

Manage sandbox port publishing.

List, publish, or unpublish sandbox ports. Publishing a local port starts a stopped sandbox before creating the host binding. Without --publish or --unpublish flags, lists all published ports.

Port spec format: [[HOST_IP:]HOST_PORT:]SANDBOX_PORT[/PROTOCOL] If HOST_PORT is omitted, an ephemeral port is allocated automatically. If HOST_IP is omitted, the port is bound on loopback, expanded based on PROTOCOL and the sandbox's address families: tcp/udp binds both 127.0.0.1 and ::1 (or only 127.0.0.1 if the sandbox is IPv4-only); tcp4/udp4 binds only 127.0.0.1; tcp6/udp6 binds only ::1. Supported protocols: tcp, tcp4, tcp6, udp, udp4, udp6.

When publishing without a PROTOCOL, tcp4 is used — so a sandbox service listening only on IPv4 is reachable without a host client having to avoid ::1 — or tcp6 when HOST_IP is an IPv6 address. Publish tcp explicitly to bind both families.

When unpublishing without a PROTOCOL, the mapping is removed whether it was published with that same default or as dual-stack tcp. Name the protocol to remove a tcp6 or udp mapping; anything left behind is reported.

With --cloud: Manage the exposed ports of a cloud sandbox.

List, publish, or unpublish ports on a cloud sandbox given by ID (sbx_*) or name. Without --publish or --unpublish flags, lists the exposed ports.

A port is the sandbox port number alone or with a /tcp suffix; UDP and host bindings are refused. The cloud control plane assigns a publicly reachable URL for each exposed port.

Options

オプションデフォルト内容説明
--jsonOutput in JSON format (for port listing)
--publishPublish a port (can be repeated): [[HOST_IP:]HOST_PORT:]SANDBOX_PORT[/PROTOCOL] (local) or SANDBOX_PORT[/tcp] (cloud)
--unpublishUnpublish a port (can be repeated): [HOST_IP:]HOST_PORT:SANDBOX_PORT[/PROTOCOL] (local) or SANDBOX_PORT[/tcp] (cloud)

Global options

オプションデフォルト内容説明
--cloudDispatch to Docker Cloud Sandboxes API instead of local sandboxd (supported by a growing set of verbs — run 'sbx --cloud --help' for the current list)
-D, --debugEnable debug logging

Examples

# List published ports
sbx ports my-sandbox

# Publish sandbox port 8080 to an ephemeral host port
sbx ports my-sandbox --publish 8080

# Publish with a specific host port
sbx ports my-sandbox --publish 3000:8080

# Unpublish a port
sbx ports my-sandbox --unpublish 3000:8080

# Expose port 8080 on a cloud sandbox
sbx --cloud ports sbx_abc123 --publish 8080

# Remove an exposed port from a cloud sandbox
sbx --cloud ports sbx_abc123 --unpublish 8080