Container
The Docker containers of the host. osapi dsl behavior get --name docker and
osapi dsl behavior method get show the same.
Behavior
| Name | docker |
| Description | The Docker containers of the host |
| Placement | node |
| Area | containers |
| Internal | no |
| API | yes |
| CLI | yes |
| Next | no |
| Platforms | linux, darwin |
| Sudo | docker |
| Runs | docker |
| Writes | none |
| Keeps state | no |
| Uses | none |
| Used by | none |
Methods (7)
| NAME | VERB | HTTP | ROUTE | PERMISSION | DESCRIPTION |
|---|---|---|---|---|---|
| list | read | GET | /api/node/{hostname}/docker | docker:read | List the containers of the host |
| get | read | GET | /api/node/{hostname}/docker/{name} | docker:read | Get one container |
| create | write | POST | /api/node/{hostname}/docker | docker:write | Create a container |
| delete | write | DELETE | /api/node/{hostname}/docker/{name} | docker:write | Remove a container |
| start | write | POST | /api/node/{hostname}/docker/{name}/start | docker:write | Start a container |
| stop | write | POST | /api/node/{hostname}/docker/{name}/stop | docker:write | Stop a container |
| exec | write | POST | /api/node/{hostname}/docker/{name}/exec | docker:write | Run a command in a container |
Types (7)
| NAME | INPUT | OUTPUT |
|---|---|---|
| list | ListInput { state } | []Entry { id, name, image, state, summary, created, health, ports, mounts, networks, env_names } |
| get | GetInput { name* } | Entry { id, name, image, state, summary, created, health, ports, mounts, networks, env_names } |
| create | CreateInput { name*, image*, container_hostname, dns, command, env, ports, volumes, auto_start } | Result { name, id, changed } |
| delete | DeleteInput { name* } | Result { name, id, changed } |
| start | StartInput { name* } | Result { name, id, changed } |
| stop | StopInput { name*, timeout } | Result { name, id, changed } |
| exec | ExecInput { name*, command*, env, working_dir } | ExecResult { stdout, stderr, exit_code, changed } |
Settings (0)
None. Declare them with behavior.Config.
Telemetry
| Span | behavior.docker.<method> |
| Child spans | exec docker |
| Metrics | osapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total |
| Attributes | osapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed |
| Recorded inputs | name (get, create, delete, start, stop, exec) |
Method list
| Name | list |
| Verb | read |
| Description | List the containers of the host |
| Detail | Reads each container through gohai's docker collector, which runs docker ps and docker inspect. state limits the list to the running or the stopped ones. A host whose docker does not answer reports skipped. The environment of a container shows only the names of its variables: osapi never reads their values. |
| HTTP | GET |
| Route | /api/node/{hostname}/docker |
| Permission | docker:read |
| Command | osapi client node docker list |
| Input type | ListInput |
| Output type | []Entry |
Input (1)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| state | string | no | one of running stopped all | Only the containers in this state: running, stopped or all, the default |
Output (11)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| id | string | The container's full ID |
| name | string | The container's name |
| image | string | The image it runs |
| state | string | running, exited, created, paused or restarting |
| summary | string | What docker says of its state, such as Up 2 minutes |
| created | string | When it was created, RFC 3339 |
| health | string | The state of its health check: healthy, unhealthy or starting; empty without one |
| ports | array | The published ports, host:port->container port |
| mounts | array | The mounts, source:destination, with :ro when read only |
| networks | array | The networks, with the container's address and gateway on each |
| env_names | array | The names of its environment variables; osapi never reads their values |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| A host with a container | (none) | [created=2026-11-22T10:00:00Z, env_names=[PATH APP_TOKEN], id=3f4e8a1b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7, image=alpine:3.20, mounts=[/srv/data:/data:ro], name=osapitest, networks=[bridge 172.17.0.2 via 172.17.0.1], ports=[0.0.0.0:8080->80/tcp], state=running, summary=Up 2 minutes] |
| Only the stopped ones | state=stopped |
Method get
| Name | get |
| Verb | read |
| Description | Get one container |
| Detail | Reads one container by its name, its ID or the start of its ID. A container that the host does not have is not found. |
| HTTP | GET |
| Route | /api/node/{hostname}/docker/{name} |
| Permission | docker:read |
| Command | osapi client node docker get |
| Input type | GetInput |
| Output type | Entry |
Input (1)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ | The container's name or ID |
Output (11)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| id | string | The container's full ID |
| name | string | The container's name |
| image | string | The image it runs |
| state | string | running, exited, created, paused or restarting |
| summary | string | What docker says of its state, such as Up 2 minutes |
| created | string | When it was created, RFC 3339 |
| health | string | The state of its health check: healthy, unhealthy or starting; empty without one |
| ports | array | The published ports, host:port->container port |
| mounts | array | The mounts, source:destination, with :ro when read only |
| networks | array | The networks, with the container's address and gateway on each |
| env_names | array | The names of its environment variables; osapi never reads their values |
Examples (1)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| A container | name=osapitest | id=3f4e8a1b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7, name=osapitest, image=alpine:3.20, state=running, summary=Up 2 minutes, created=2026-11-22T10:00:00Z, ports=[0.0.0.0:8080->80/tcp], mounts=[/srv/data:/data:ro], networks=[bridge 172.17.0.2 via 172.17.0.1], env_names=[PATH APP_TOKEN] |
Method create
| Name | create |
| Verb | write |
| Description | Create a container |
| Detail | Runs docker create, which pulls the image when the host does not have it. The environment goes on docker's standard input, not in its arguments, which each user of the host can read. auto_start starts the container once it is made. A container of the name that the host has already is not made again, and reports changed: false. |
| HTTP | POST |
| Route | /api/node/{hostname}/docker |
| Permission | docker:write |
| Command | osapi client node docker create |
| Input type | CreateInput |
| Output type | Result |
Input (9)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ | The container's name |
| image | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9._/:@-]*$ | The image to run, such as alpine:3.20; docker pulls it when the host does not have it |
| container_hostname | string | no | pattern ^[a-zA-Z0-9][a-zA-Z0-9.-]*$, max length 253 | The hostname inside the container |
| dns | array | no | The DNS servers of the container | |
| command | array | no | The command, in place of the image's own | |
| env | object | no | The environment variables of the container. A secret: a reference, secret://<vault>/<key>, or the value. | |
| ports | array | no | The published ports, each host:container, such as 8080:80 | |
| volumes | array | no | The bind mounts, each host:container, such as /srv/data:/data | |
| auto_start | boolean | no | Start the container once it is created |
Output (3)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The container |
| id | string | The container's full ID, for create |
| changed | boolean | Whether the host changed |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Create a container | name=osapitest, image=alpine:3.20, command=[sleep 300] | name=osapitest, id=3f4e8a1b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7, changed=true |
| A container that the host has | name=osapitest, image=alpine:3.20, command=[sleep 300] | name=osapitest, id=3f4e8a1b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7, changed=false |
Method delete
| Name | delete |
| Verb | write |
| Description | Remove a container |
| Detail | Runs docker rm -f, which also removes a container that runs: a delete leaves no container of the name. A container that the host does not have reports changed: false. |
| HTTP | DELETE |
| Route | /api/node/{hostname}/docker/{name} |
| Permission | docker:write |
| Command | osapi client node docker delete |
| Input type | DeleteInput |
| Output type | Result |
Input (1)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ | The container's name or ID |
Output (3)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The container |
| id | string | The container's full ID, for create |
| changed | boolean | Whether the host changed |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Remove a container | name=osapitest | name=osapitest, changed=true |
| A container that the host does not have | name=osapitest | name=osapitest, changed=false |
Method start
| Name | start |
| Verb | write |
| Description | Start a container |
| Detail | Runs docker start. A container that runs already reports changed: false, and one that the host does not have is not found. |
| HTTP | POST |
| Route | /api/node/{hostname}/docker/{name}/start |
| Permission | docker:execute |
| Command | osapi client node docker start |
| Input type | StartInput |
| Output type | Result |
Input (1)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ | The container's name or ID |
Output (3)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The container |
| id | string | The container's full ID, for create |
| changed | boolean | Whether the host changed |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Start a container | name=osapitest | name=osapitest, changed=true |
| A container that runs already | name=osapitest | name=osapitest, changed=false |
Method stop
| Name | stop |
| Verb | write |
| Description | Stop a container |
| Detail | Runs docker stop, which waits timeout seconds before docker kills the container, or docker's default of 10 when it is 0. A container that does not run reports changed: false. |
| HTTP | POST |
| Route | /api/node/{hostname}/docker/{name}/stop |
| Permission | docker:execute |
| Command | osapi client node docker stop |
| Input type | StopInput |
| Output type | Result |
Input (2)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ | The container's name or ID |
| timeout | integer | no | min 0, max 300 | Seconds to wait before docker kills it; docker's default when 0 |
Output (3)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The container |
| id | string | The container's full ID, for create |
| changed | boolean | Whether the host changed |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Stop a container | name=osapitest, timeout=1 | name=osapitest, changed=true |
| A container that does not run | name=osapitest, timeout=1 | name=osapitest, changed=false |
Method exec
| Name | exec |
| Verb | write |
| Description | Run a command in a container |
| Detail | Runs docker exec, and answers what the command wrote to standard output and to standard error, and its exit code. A command that exits with a code other than 0 is an answer, not a failure. It changes what the command changes, which osapi cannot tell, so it reports changed: true. Its permission is docker:exec, which only the admin role gets, apart from the docker:execute of start and stop. An agent with agent.command.enabled false refuses it, as it refuses a command. |
| HTTP | POST |
| Route | /api/node/{hostname}/docker/{name}/exec |
| Permission | docker:exec |
| Command | osapi client node docker exec |
| Input type | ExecInput |
| Output type | ExecResult |
Input (4)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ | The container's name or ID |
| command | array | yes | The command and its arguments | |
| env | object | no | Environment variables for the command. A secret: a reference, secret://<vault>/<key>, or the value. | |
| working_dir | string | no | pattern ^/ | The directory the command runs in |
Output (4)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| stdout | string | What the command wrote to standard output |
| stderr | string | What the command wrote to standard error |
| exit_code | integer | The command's exit code |
| changed | boolean | Always true: osapi cannot tell what the command changed |
Examples (1)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Run a command | name=osapitest, command=[echo hello] | stdout=hello , stderr=, exit_code=0, changed=true |