docker://¶
Docker Engine API integration via raw HTTP over a Unix socket or TCP. The component speaks the Docker Engine REST API directly with stdlib net/http, no external Docker SDK. Useful for orchestrating containers from a workflow — pulling images, starting / stopping containers, tailing logs, running one-shot exec commands.
Producer-only — CreateConsumer returns an error.
URI shape¶
docker://<operation>?host=unix:///var/run/docker.sock
docker://<operation>?host=tcp://docker-host:2375
| Operation | Endpoint |
|---|---|
containers/list |
GET /containers/json |
containers/create |
POST /containers/create |
containers/start |
POST /containers/{id}/start |
containers/stop |
POST /containers/{id}/stop |
containers/logs |
GET /containers/{id}/logs?stdout=true&stderr=true |
containers/inspect |
GET /containers/{id}/json |
images/list |
GET /images/json |
images/pull |
POST /images/create?fromImage=...&tag=... |
exec |
POST /containers/{id}/exec + POST /exec/{execId}/start |
Parameters¶
| Param | Type | Default | Producer/Consumer/Both | Description |
|---|---|---|---|---|
(path) operation |
string | required | Producer | One of the operations above. |
host |
string | unix:///var/run/docker.sock |
Producer | Docker host. unix://<path> dials a Unix socket; tcp://<host:port> or http(s)://<host:port> uses TCP. |
Headers¶
Read by the producer¶
| Header | Operation | Description |
|---|---|---|
docker.containerId |
start, stop, logs, inspect, exec | Container ID to act on. |
docker.containerName |
create | Optional ?name= query param. |
docker.image |
images/pull | Image name (or use body). |
docker.tag |
images/pull | Tag — default latest. |
docker.all |
containers/list | When "true", lists all containers (including stopped). |
docker.tail |
containers/logs | ?tail=N parameter. |
docker.since |
containers/logs | ?since=... parameter (RFC3339 / Unix). |
Written by the producer¶
| Header | Operation | Description |
|---|---|---|
docker.containerId |
create | The newly-created container's ID (extracted from the JSON response). |
docker.execId |
exec | The exec instance ID. |
The body becomes either the request JSON (create, exec config) or — for images/pull and exec — a fallback shell command read directly from BodyAsString().
Examples¶
Pull an image and run a one-shot container:
workflows:
- id: scrape
trigger: { uri: direct://scrape }
steps:
- set-header:
name: docker.image
constant: "alpine"
- target: docker://images/pull
- set-body:
starlang: '{ "Image": "alpine", "Cmd": ["echo", "hello"], "AttachStdout": true }'
- target: docker://containers/create
- target: docker://containers/start
Tail container logs:
- set-header:
name: docker.containerId
constant: my-app
- set-header:
name: docker.tail
constant: "100"
- target: docker://containers/logs
Run a shell command via exec:
- set-header:
name: docker.containerId
constant: my-app
- set-body:
constant: "ls -la /app"
- target: docker://exec
Talk to a remote Docker host:
Behavior notes¶
- No TLS auth helpers —
host=tcp://...opens a plain TCP socket. For TLS-protected Docker daemons, front them withhost=https://...and rely on system root CAs (no client-cert support in this component today). - 120 s timeout — both the socket and TCP transports use a 120 s timeout. Image pulls of large images can hit this; consider running the pull out-of-band if needed.
execis two calls —createreturns an exec ID;startactually runs the command. The body of the response is what the executed command wrote to its attached streams (text, with no chunk framing).304 Not Modifiedis treated as success forstart/stop— the container was already in that state.
Source¶
pkg/component/docker/docker.go
See also¶
- kubernetes connectors — for K8s-driven orchestration.
- http — for any Docker Registry / build-system REST APIs not covered here.