Add ports option to docker() sandbox provider#519
Open
OthmanAdi wants to merge 3 commits intomattpocock:mainfrom
Open
Add ports option to docker() sandbox provider#519OthmanAdi wants to merge 3 commits intomattpocock:mainfrom
OthmanAdi wants to merge 3 commits intomattpocock:mainfrom
Conversation
When an agent starts a web server inside the sandbox, the container is
created without port mappings by default, making the service unreachable
from the host. The new ports option maps each declared port as -p <port>:<port>
in the docker run command.
docker({ ports: [3000, 5173] })
Changes:
- StartContainerOptions: add ports?: readonly number[]
- startContainer(): generate portFlags and splice into docker run args
- DockerOptions: add ports?: readonly number[] with JSDoc and example
- docker(): pass ports through to startContainer
- DockerLifecycle.test.ts: 3 tests (single port, multiple ports, omitted)
- docker.test.ts: 2 acceptance tests
- .changeset/docker-ports-option.md: patch changeset
|
@OthmanAdi is attempting to deploy a commit to the Matt Pocock's projects Team on Vercel. A member of the Team first needs to authorize it. |
OthmanAdi
added a commit
to OthmanAdi/OthmanAdi
that referenced
this pull request
May 1, 2026
Upgrade ports type from number[] to (number | string)[] so callers
can declare either symmetric or asymmetric port mappings:
docker({ ports: [3000, 8000] }) // -p 3000:3000 -p 8000:8000
docker({ ports: ["3001:3000"] }) // -p 3001:3000
docker({ ports: [5173, "3001:3000"] }) // mixed
Works for any language or framework — Python, Rust, Ruby, Angular,
Astro, React, Vue, TanStack, Next.js, etc.
Add 3 new tests: string entry pass-through, string array acceptance,
mixed number/string array acceptance. 29/29 passing.
Mirror the docker() ports feature for podman(). Same type: readonly ports?: readonly (number | string)[] Same behavior: number → -p port:port, string → -p host:container. Works for any language/framework running inside a Podman sandbox. Add 7 tests: 3 acceptance, 4 integration (single port, multiple ports, asymmetric string, omitted). Integration tests follow the same pattern as existing network tests — will pass on Linux CI like all other podman integration tests. Update changeset to cover both docker() and podman().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When an agent starts a web server inside the sandbox container, the container is created without port mappings. The host cannot reach the service on any port the agent opens.
The workaround is a manual socat sidecar:
This is not a viable option for end users.
Solution
Add a
portsoption to thedocker()sandbox provider. Each declared port is mapped as-p <port>:<port>in thedocker runcommand, making the port reachable from the host.Changes
src/DockerLifecycle.tsports?: readonly number[]toStartContainerOptions, generate-p <port>:<port>flagssrc/sandboxes/docker.tsports?: readonly number[]toDockerOptions, pass through tostartContainersrc/DockerLifecycle.test.tssrc/sandboxes/docker.test.ts.changeset/docker-ports-option.mdTest plan
npm test -- src/DockerLifecycle.test.ts src/sandboxes/docker.test.ts— 26/26 pass@daytona/sdkpeer dep issue