Skip to main content

Container

The Docker containers of the host. osapi dsl behavior get --name docker and osapi dsl behavior method get show the same.

Behavior​

Namedocker
DescriptionThe Docker containers of the host
Placementnode
Areacontainers
Internalno
APIyes
CLIyes
Nextno
Platformslinux, darwin
Sudodocker
Runsdocker
Writesnone
Keeps stateno
Usesnone
Used bynone

Methods (7)​

NAMEVERBHTTPROUTEPERMISSIONDESCRIPTION
listreadGET/api/node/{hostname}/dockerdocker:readList the containers of the host
getreadGET/api/node/{hostname}/docker/{name}docker:readGet one container
createwritePOST/api/node/{hostname}/dockerdocker:writeCreate a container
deletewriteDELETE/api/node/{hostname}/docker/{name}docker:writeRemove a container
startwritePOST/api/node/{hostname}/docker/{name}/startdocker:writeStart a container
stopwritePOST/api/node/{hostname}/docker/{name}/stopdocker:writeStop a container
execwritePOST/api/node/{hostname}/docker/{name}/execdocker:writeRun a command in a container

Types (7)​

NAMEINPUTOUTPUT
listListInput { state }[]Entry { id, name, image, state, summary, created, health, ports, mounts, networks, env_names }
getGetInput { name* }Entry { id, name, image, state, summary, created, health, ports, mounts, networks, env_names }
createCreateInput { name*, image*, container_hostname, dns, command, env, ports, volumes, auto_start }Result { name, id, changed }
deleteDeleteInput { name* }Result { name, id, changed }
startStartInput { name* }Result { name, id, changed }
stopStopInput { name*, timeout }Result { name, id, changed }
execExecInput { name*, command*, env, working_dir }ExecResult { stdout, stderr, exit_code, changed }

Settings (0)​

None. Declare them with behavior.Config.

Telemetry​

Spanbehavior.docker.<method>
Child spansexec docker
Metricsosapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total
Attributesosapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed
Recorded inputsname (get, create, delete, start, stop, exec)

Method list​

Namelist
Verbread
DescriptionList the containers of the host
DetailReads 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.
HTTPGET
Route/api/node/{hostname}/docker
Permissiondocker:read
Commandosapi client node docker list
Input typeListInput
Output type[]Entry

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
statestringnoone of running stopped allOnly the containers in this state: running, stopped or all, the default

Output (11)​

FIELDTYPEDESCRIPTION
idstringThe container's full ID
namestringThe container's name
imagestringThe image it runs
statestringrunning, exited, created, paused or restarting
summarystringWhat docker says of its state, such as Up 2 minutes
createdstringWhen it was created, RFC 3339
healthstringThe state of its health check: healthy, unhealthy or starting; empty without one
portsarrayThe published ports, host:port->container port
mountsarrayThe mounts, source:destination, with :ro when read only
networksarrayThe networks, with the container's address and gateway on each
env_namesarrayThe names of its environment variables; osapi never reads their values

Examples (2)​

EXAMPLEINPUTOUTPUT
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 onesstate=stopped

Method get​

Nameget
Verbread
DescriptionGet one container
DetailReads one container by its name, its ID or the start of its ID. A container that the host does not have is not found.
HTTPGET
Route/api/node/{hostname}/docker/{name}
Permissiondocker:read
Commandosapi client node docker get
Input typeGetInput
Output typeEntry

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$The container's name or ID

Output (11)​

FIELDTYPEDESCRIPTION
idstringThe container's full ID
namestringThe container's name
imagestringThe image it runs
statestringrunning, exited, created, paused or restarting
summarystringWhat docker says of its state, such as Up 2 minutes
createdstringWhen it was created, RFC 3339
healthstringThe state of its health check: healthy, unhealthy or starting; empty without one
portsarrayThe published ports, host:port->container port
mountsarrayThe mounts, source:destination, with :ro when read only
networksarrayThe networks, with the container's address and gateway on each
env_namesarrayThe names of its environment variables; osapi never reads their values

Examples (1)​

EXAMPLEINPUTOUTPUT
A containername=osapitestid=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​

Namecreate
Verbwrite
DescriptionCreate a container
DetailRuns 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.
HTTPPOST
Route/api/node/{hostname}/docker
Permissiondocker:write
Commandosapi client node docker create
Input typeCreateInput
Output typeResult

Input (9)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$The container's name
imagestringyespattern ^[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_hostnamestringnopattern ^[a-zA-Z0-9][a-zA-Z0-9.-]*$, max length 253The hostname inside the container
dnsarraynoThe DNS servers of the container
commandarraynoThe command, in place of the image's own
envobjectnoThe environment variables of the container. A secret: a reference, secret://<vault>/<key>, or the value.
portsarraynoThe published ports, each host:container, such as 8080:80
volumesarraynoThe bind mounts, each host:container, such as /srv/data:/data
auto_startbooleannoStart the container once it is created

Output (3)​

FIELDTYPEDESCRIPTION
namestringThe container
idstringThe container's full ID, for create
changedbooleanWhether the host changed

Examples (2)​

EXAMPLEINPUTOUTPUT
Create a containername=osapitest, image=alpine:3.20, command=[sleep 300]name=osapitest, id=3f4e8a1b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7, changed=true
A container that the host hasname=osapitest, image=alpine:3.20, command=[sleep 300]name=osapitest, id=3f4e8a1b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7, changed=false

Method delete​

Namedelete
Verbwrite
DescriptionRemove a container
DetailRuns 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.
HTTPDELETE
Route/api/node/{hostname}/docker/{name}
Permissiondocker:write
Commandosapi client node docker delete
Input typeDeleteInput
Output typeResult

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$The container's name or ID

Output (3)​

FIELDTYPEDESCRIPTION
namestringThe container
idstringThe container's full ID, for create
changedbooleanWhether the host changed

Examples (2)​

EXAMPLEINPUTOUTPUT
Remove a containername=osapitestname=osapitest, changed=true
A container that the host does not havename=osapitestname=osapitest, changed=false

Method start​

Namestart
Verbwrite
DescriptionStart a container
DetailRuns docker start. A container that runs already reports changed: false, and one that the host does not have is not found.
HTTPPOST
Route/api/node/{hostname}/docker/{name}/start
Permissiondocker:execute
Commandosapi client node docker start
Input typeStartInput
Output typeResult

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$The container's name or ID

Output (3)​

FIELDTYPEDESCRIPTION
namestringThe container
idstringThe container's full ID, for create
changedbooleanWhether the host changed

Examples (2)​

EXAMPLEINPUTOUTPUT
Start a containername=osapitestname=osapitest, changed=true
A container that runs alreadyname=osapitestname=osapitest, changed=false

Method stop​

Namestop
Verbwrite
DescriptionStop a container
DetailRuns 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.
HTTPPOST
Route/api/node/{hostname}/docker/{name}/stop
Permissiondocker:execute
Commandosapi client node docker stop
Input typeStopInput
Output typeResult

Input (2)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$The container's name or ID
timeoutintegernomin 0, max 300Seconds to wait before docker kills it; docker's default when 0

Output (3)​

FIELDTYPEDESCRIPTION
namestringThe container
idstringThe container's full ID, for create
changedbooleanWhether the host changed

Examples (2)​

EXAMPLEINPUTOUTPUT
Stop a containername=osapitest, timeout=1name=osapitest, changed=true
A container that does not runname=osapitest, timeout=1name=osapitest, changed=false

Method exec​

Nameexec
Verbwrite
DescriptionRun a command in a container
DetailRuns 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.
HTTPPOST
Route/api/node/{hostname}/docker/{name}/exec
Permissiondocker:exec
Commandosapi client node docker exec
Input typeExecInput
Output typeExecResult

Input (4)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$The container's name or ID
commandarrayyesThe command and its arguments
envobjectnoEnvironment variables for the command. A secret: a reference, secret://<vault>/<key>, or the value.
working_dirstringnopattern ^/The directory the command runs in

Output (4)​

FIELDTYPEDESCRIPTION
stdoutstringWhat the command wrote to standard output
stderrstringWhat the command wrote to standard error
exit_codeintegerThe command's exit code
changedbooleanAlways true: osapi cannot tell what the command changed

Examples (1)​

EXAMPLEINPUTOUTPUT
Run a commandname=osapitest, command=[echo hello]stdout=hello , stderr=, exit_code=0, changed=true