Skip to main content

List

List the containers of the host.

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.

osapi client node docker list [flags]

Examples​

# A host with a container
osapi client node docker list --target web-01

# Only the stopped ones
osapi client node docker list --target web-01 --state stopped

Result​

A host with a container, on one host:

$ osapi client node docker list --target web-01
Results:
  HOSTNAME  STATUS  ID                                                                NAME       IMAGE        STATE    SUMMARY       CREATED              HEALTH  PORTS                 MOUNTS              NETWORKS                          ENV NAMES
  web-01    ok      3f4e8a1b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7  osapitest  alpine:3.20  running  Up 2 minutes  2026-11-22 10:00:00          0.0.0.0:8080->80/tcp  /srv/data:/data:ro  bridge 172.17.0.2 via 172.17.0.1  PATH, APP_TOKEN

  1 host: 1 ok   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

On each host, where one cannot run it:

$ osapi client node docker list --target _all
Results:
  HOSTNAME  STATUS  ID                                                                NAME       IMAGE        STATE    SUMMARY       CREATED              HEALTH  PORTS                 MOUNTS              NETWORKS                          ENV NAMES
  web-01    ok      3f4e8a1b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7  osapitest  alpine:3.20  running  Up 2 minutes  2026-11-22 10:00:00          0.0.0.0:8080->80/tcp  /srv/data:/data:ro  bridge 172.17.0.2 via 172.17.0.1  PATH, APP_TOKEN
  web-02    ok      3f4e8a1b2c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f7  osapitest  alpine:3.20  running  Up 2 minutes  2026-11-22 10:00:00          0.0.0.0:8080->80/tcp  /srv/data:/data:ro  bridge 172.17.0.2 via 172.17.0.1  PATH, APP_TOKEN

  3 hosts: 2 ok, 1 skipped   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

Details:
  mac-01  skipped  operation not supported on this OS family

With --json, the API's response:

{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": [
{
"created": "2026-11-22T10:00:00Z",
"env_names": ["PATH", "APP_TOKEN"],
"hostname": "web-01",
"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-\u003e80/tcp"],
"state": "running",
"status": "ok",
"summary": "Up 2 minutes"
}
]
}

Only the stopped ones, on one host:

$ osapi client node docker list --target web-01 --state stopped
Results:
  None.

On each host, where one cannot run it:

$ osapi client node docker list --target _all --state stopped
Results:

  1 host: 1 skipped   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

Details:
  mac-01  skipped  operation not supported on this OS family

With --json, the API's response:

{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": []
}

The command fails in these cases:

CallFlagsFails with
A state that is not one--state pausedenum

Permission​

It needs the docker:read permission. osapi controller role get --name <role> shows what a role grants.

Flags​

FlagDescriptionDefault
--stateOnly the containers in this state: running, stopped or all, the default (running, stopped, all)
-T, --targetTarget: _all, _any, hostname, or label (group:web.dev)_all

Global flags​

FlagDescriptionDefault
-d, --debugEnable or disable debug mode
-j, --jsonEnable JSON output
-f, --osapi-filePath to config file; without one at the default path, osapi runs on the defaults/etc/osapi/osapi.yaml
--urlBase URL the CLI client connects to (controller.client.url)https://localhost:8080

Output tells how the result is printed, and what --json gives.