qodalis-cli-server-plugin-docker 1.0.0b39__tar.gz → 1.0.0b40__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/PKG-INFO +86 -5
  2. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/README.md +84 -3
  3. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/pyproject.toml +2 -2
  4. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/__init__.py +37 -0
  5. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/builder.py +18 -3
  6. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/commands.py +133 -5
  7. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/compose.py +10 -0
  8. qodalis_cli_server_plugin_docker-1.0.0b40/qodalis_cli_docker/compose_rules.py +207 -0
  9. qodalis_cli_server_plugin_docker-1.0.0b40/qodalis_cli_docker/console/extension.css +32 -0
  10. qodalis_cli_server_plugin_docker-1.0.0b40/qodalis_cli_docker/console/extension.js +91 -0
  11. qodalis_cli_server_plugin_docker-1.0.0b40/qodalis_cli_docker/containers.py +1379 -0
  12. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/controller.py +12 -0
  13. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/plugin.py +2 -0
  14. qodalis_cli_server_plugin_docker-1.0.0b40/qodalis_cli_docker/run_options.py +516 -0
  15. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/service.py +1052 -18
  16. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/settings.py +18 -0
  17. qodalis_cli_server_plugin_docker-1.0.0b39/qodalis_cli_docker/console/extension.css +0 -32
  18. qodalis_cli_server_plugin_docker-1.0.0b39/qodalis_cli_docker/console/extension.js +0 -89
  19. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/.gitignore +0 -0
  20. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/LICENSE +0 -0
  21. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/console_page.py +0 -0
  22. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/engine.py +0 -0
  23. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/exec_socket.py +0 -0
  24. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/mcp_tools.py +0 -0
  25. {qodalis_cli_server_plugin_docker-1.0.0b39 → qodalis_cli_server_plugin_docker-1.0.0b40}/qodalis_cli_docker/shapes.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: qodalis-cli-server-plugin-docker
3
- Version: 1.0.0b39
3
+ Version: 1.0.0b40
4
4
  Summary: Docker containers, images, stacks, volumes and networks plugin for Qodalis CLI servers: commands, API, MCP, exec socket and Console page
5
5
  Project-URL: Homepage, https://github.com/qodalis-solutions/cli-server-python
6
6
  Project-URL: Repository, https://github.com/qodalis-solutions/cli-server-python
@@ -22,7 +22,7 @@ Requires-Dist: fastapi>=0.100.0
22
22
  Requires-Dist: opentelemetry-api<1.46
23
23
  Requires-Dist: qodalis-cli-server-abstractions>=1.0.0b39
24
24
  Provides-Extra: users
25
- Requires-Dist: qodalis-cli-server-plugin-users>=1.0.0b39; extra == 'users'
25
+ Requires-Dist: qodalis-cli-server-plugin-users>=1.0.0b40; extra == 'users'
26
26
  Description-Content-Type: text/markdown
27
27
 
28
28
  # qodalis-cli-server-plugin-docker
@@ -87,6 +87,8 @@ read on every call, so a change applies without a restart, except hosts and TLS
87
87
  | `composeHosts` | string[] | `["local"]` | The hosts compose may change; write, `up`, compose `down` and delete on another host are 409 `compose is not enabled for host <name>` (the Engine API way of `down` for a stack without a file works on any host) |
88
88
  | `composeEnv` | string[] | `[]` | Names of the server's environment variables the compose CLI may see (for `${VAR}` in compose files); names starting with `DOCKER_` or `COMPOSE_` are ignored |
89
89
  | `composeTimeoutSeconds` | number 10-3600 | 900 | Time limit of one compose `up` (`down` has 120 s) |
90
+ | `bindMounts` | string[] | `[]` | Host folders a created or edited container may bind-mount (absolute paths); a bind source must be one of them or lie under one, compared as text after normalizing (`.`, `..`, repeated and trailing `/` removed; a source that climbs above `/` is refused). The folders are on the engine's machine, so the server cannot resolve links there: list only folders whose content the admins control. Empty: 400 `bind mounts are not allowed (see the bindMounts setting)`; outside: 400 `bind mount <source> is outside the allowed folders` |
91
+ | `allowPrivileged` | boolean | false | Allow the settings that give a container power over the host: `privileged`, `capAdd`, `devices`, `securityOpt`, `networkMode`/`pidMode`/`ipcMode`/`usernsMode`/`cgroupnsMode` `host`. Off: 400 `<field> needs the allowPrivileged setting`. An edit keeps a value the container already has; only what it adds is checked |
90
92
  | `allowUnprotected` | boolean | false | Serve callers that are not signed in (a server without the users plugin's protection); off: see the first rule below |
91
93
  | `timeoutSeconds` | number 1-120 | 15 | Timeout of one Engine API call (not of streams, pulls or exec) |
92
94
 
@@ -123,7 +125,7 @@ prefix of at least 3 characters or a name.
123
125
  | `GET /containers?all=&stack=`, `/containers/{id}` | read | containers sorted by name; one with its detail (command, masked environment, mounts, networks) |
124
126
  | `GET /containers/{id}/logs?tail=&since=&timestamps=` | read | `{ host, lines }`, oldest first |
125
127
  | `GET /stats?ids=` | read | CPU, memory, network, block I/O and pids (two samples per container) |
126
- | `GET /compose` | read | `{ available, version?, roots, error? }`: whether the compose CLI answers (`version --short`, 5 s, cached 60 s) |
128
+ | `GET /compose` | read | `{ available, version?, roots, error?, bindMounts, allowPrivileged }`: whether the compose CLI answers (`version --short`, 5 s, cached 60 s), and what the container form may offer (the normalized `bindMounts` and `allowPrivileged`) |
127
129
  | `GET /images`, `/stacks`, `/stacks/{name}`, `/volumes[/{name}]`, `/networks[/{id}]` | read | lists and details; a stack has `composeFile` (the path found by the rule) and the state `down` when only its folder exists |
128
130
  | `GET /operations`, `/operations/{id}` | read | the last 50 operations (pulls, stack updates), newest first |
129
131
  | `POST /containers/{id}/start\|stop\|restart\|kill\|pause\|unpause` | manage | `{ ok, container }` |
@@ -131,6 +133,9 @@ prefix of at least 3 characters or a name.
131
133
  | `POST /stacks/{name}/start\|stop\|restart` | manage | `{ ok, results }` per container (a protected one is reported, the rest run) |
132
134
  | `POST /stacks/{name}/pull` | manage | 202 `{ operation }` |
133
135
  | `POST /exec/{id}` `{ command, user?, workdir?, timeoutSeconds? }` | exec | `{ exitCode, stdout, stderr, truncated }` (1 MB per stream; 504 on timeout) |
136
+ | `GET /admin/containers/{id}/spec` | admin | `{ host, spec, stack, editable, reason? }`: the container's configuration as a ContainerSpec (see Creating and editing containers) |
137
+ | `POST /admin/containers` `{ spec, start?, pull? }` | admin | 202 `{ operation }` (kind `container-create`) |
138
+ | `PUT /admin/containers/{id}` `{ spec, pull? }` | admin | 202 `{ operation }` (kind `container-update`): an in-place update or a recreate |
134
139
  | `DELETE /admin/containers/{id}?force=&volumes=`, `POST /admin/containers/prune` | admin | `{ ok }`; `{ removed, reclaimedBytes }` (hidden and protected containers are never pruned) |
135
140
  | `DELETE /admin/images/{id}?force=`, `POST /admin/images/prune` `{ all? }` | admin | `{ ok, untagged, deleted }`; `{ removed, reclaimedBytes }` |
136
141
  | `POST /admin/volumes`, `DELETE /admin/volumes/{name}?force=`, `POST /admin/volumes/prune` | admin | 201 `{ volume }`; `{ ok }`; `{ removed, reclaimedBytes }` |
@@ -177,6 +182,8 @@ printed (the route's answer indented by 2); destructive commands ask first (`--y
177
182
  | `docker stats [container] [--watch]` | read | `--watch` refreshes the table every 2 s |
178
183
  | `docker start\|stop\|restart\|kill\|pause\|unpause <container...>` | manage | one line per container; exit 1 when any failed |
179
184
  | `docker rm <container...> [--force] [--volumes] [--yes]` | admin | asks first |
185
+ | `docker run [options] <image> [command...]`, `docker create [options] <image> [command...]` | admin | creates (and starts, for `run`) a container; the options are the Docker CLI's, before the image, everything after it is the command (see below). A progress block, then `Created <name> (<shortId>), <state>` |
186
+ | `docker update [--restart <policy>[:<n>]] [--memory <size>] [--memory-reservation <size>] [--memory-swap <size>] [--cpus <n>] [--cpu-shares <n>] [--cpuset-cpus <list>] [--pids-limit <n>] <container>` | admin | an in-place change only; removing a limit is refused (edit the container to recreate it) |
180
187
  | `docker exec [options] <container> [<command...>]` | exec | options `-i`, `-t`, `-it`, `--interactive`, `--tty`, `--user`/`-u`, `--workdir`/`-w`, `--timeout <s>`, `--host` go BEFORE the container (as in the docker CLI); everything after the container is the command, flags included, taken from the raw line and split like a shell line: `docker exec web ls -la /`, `docker exec -u root web sh -c "echo a; exit 3"`. Output: stdout, then stderr (warning); the command's exit code |
181
188
  | `docker images`, `docker images prune [--all] [--yes]` | read; admin | |
182
189
  | `docker pull <image>` | manage | progress until done |
@@ -193,6 +200,75 @@ printed (the route's answer indented by 2); destructive commands ask first (`--y
193
200
  | `docker networks create <name> [--driver <d>] [--internal] [--subnet <cidr>]`, `rm <name...> [--yes]`, `prune [--yes]` | admin | |
194
201
  | `docker system info`, `system df`, `system events [--since <1h>] [--follow]` | read | |
195
202
 
203
+ ## Creating and editing containers
204
+
205
+ `docker:admin` only, refused in read-only mode, audited (`docker.container.create`, `docker.container.update`; properties
206
+ `{ host, image, recreated }`, never the spec: its env can hold secrets). Docker cannot change most of a container's
207
+ configuration in place, so an **edit recreates the container under the same name** (its volumes are kept), except for the
208
+ few settings the engine updates in place.
209
+
210
+ **ContainerSpec** (the body's `spec`): `name`, `image` (required; no tag means `:latest`), `command`, `entrypoint` (`[""]`
211
+ clears the image's), `workdir`, `user`, `hostname`, `domainname`, `env` (`NAME=value`, 200 at most), `labels` (100 at most;
212
+ `com.docker.compose.*` is reserved), `tty`, `openStdin`, `ports` (`{ private, public?, ip?, type? }`), `publishAll`, `mounts`
213
+ (`{ type: volume|bind|tmpfs, source?, destination, readOnly?, tmpfsSizeBytes? }`), `networkMode`, `networks`
214
+ (`{ name, aliases?, ipv4Address?, ipv6Address? }`: the first one, or the one `networkMode` names, is used at create, the
215
+ others are connected before the start), `dns`, `dnsSearch`, `dnsOptions`, `extraHosts`, `restartPolicy`, `maxRetries`,
216
+ `memoryBytes` (0 or at least 6 MB), `memoryReservationBytes`, `memorySwapBytes`, `cpus`, `cpuShares`, `cpusetCpus`,
217
+ `pidsLimit`, `shmSizeBytes`, `ulimits`, `healthcheck` (`{ test, intervalSeconds?, timeoutSeconds?, startPeriodSeconds?, retries? }`),
218
+ `stopSignal`, `stopTimeoutSeconds`, `init`, `readOnlyRootfs`, `autoRemove`, `logDriver`, `logOptions`, `sysctls`, `capAdd`,
219
+ `capDrop`, `privileged`, `devices`, `securityOpt`, `pidMode`, `ipcMode`, `usernsMode`, `cgroupnsMode` and `platform` (create
220
+ only). An unknown field is 400 `unknown field <name>`; `null` counts as missing. Nothing but what the spec sets is sent to
221
+ the engine's create call.
222
+
223
+ - `GET /admin/containers/{id}/spec` returns what a person would have written: only the fields that differ from the image's
224
+ or the engine's defaults. Secret-like env values are `••••••`; sending `NAME=••••••` back keeps the container's value
225
+ (a name it does not have: 400 `env <NAME> has no value to keep`). Anonymous volumes come back with their volume name as
226
+ `source`, so an edit keeps their data. `editable` is false with a `reason` for a protected container and for one that
227
+ belongs to a compose stack (`container <name> belongs to stack <stack>; change the stack's compose file`).
228
+ - Create: pull as asked (`pull`: `missing` (default), `always`, `never`: with the image missing it fails `image <image> is not on host <host>`),
229
+ create, connect the other networks, start when `start` (default true). A failed start leaves the created container (as
230
+ `docker run` does): the operation fails with the engine's message and carries `result.container`.
231
+ - The spec of an edit is the whole desired state of the fields a ContainerSpec has: a field left out means the image's or the engine's default (a limit is removed, `command` is the image's), and an explicit `0`, `""`, `false` or `[]` means the same; only settings a spec cannot express are kept from the container. An existing bind mount (same source and destination) is kept without the `bindMounts` check. Health check durations may be fractional seconds (nanoseconds, rounded down).
232
+ - Edit: when only `restartPolicy`, `maxRetries`, `memoryBytes`, `memoryReservationBytes`, `memorySwapBytes`, `cpus`,
233
+ `cpuShares`, `cpusetCpus` and `pidsLimit` differ, the engine's update call runs (no restart; message `updated in place`).
234
+ Otherwise the container is recreated: the new one is made as `<name>-next-<6 hex>` from the old one's whole configuration with
235
+ the spec's fields applied (what the spec does not express, set by another tool, is kept), its other networks connected,
236
+ the old one stopped when it was running and renamed `<name>-old-<6 hex>`, the new one renamed and started, the old one
237
+ removed (without its volumes). A failure after the old one was stopped or renamed puts it back (the new one is removed,
238
+ the old one renamed back and started when it was running) and the operation fails with `<engine message>; the old container was restored`.
239
+ The id changes; `result.container` is the new container (the restored one after a restore).
240
+ - Checked before the operation starts (the answer is the error, no operation): the spec (400), `bindMounts` and
241
+ `allowPrivileged` (400), a name or labels that a `hide` or `protect` pattern would match (409 `container <name> would be hidden or protected`), an existing container
242
+ with the new name (409 `a container named <name> already exists`), an unknown network (404 `no such network: <name>`), a hidden (404), protected (409) or stack (409) container being edited.
243
+ - Rules found in review (create and edit alike):
244
+ - `autoRemove`: an edit that needs a recreate is 409 `container <name> removes itself when stopped (autoRemove); it cannot be recreated` (the engine would remove the old container when it stops); an in-place edit still works.
245
+ - `networkMode`, `pidMode` and `ipcMode` of the form `container:<x>` resolve `<x>` through the visible list: hidden or unknown is 404 `no such container: <x>`, protected 409 `container <name> is protected`; a target that is privileged or uses a host namespace needs `allowPrivileged`. A value the container already has is kept on an edit.
246
+ - A volume used by a hidden container is 404 `no such volume: <source>`; one used by a protected container may only be mounted read-only (409 `volume <source> belongs to protected container <name>`). Mounts a container already has are kept on an edit.
247
+ - A container that already has `allowPrivileged` fields needs the setting to change its `image`, `command`, `entrypoint` or `user` (400 `<field> needs the allowPrivileged setting`).
248
+ - A create refuses `NAME=••••••` (400 `env <NAME> has no value to keep`); an edit keeps the value.
249
+ - The spec read leaves out `hostname` and `domainname` when the network mode is `host` or `container:*`. `stopTimeoutSeconds` is 0 to 2147483647; durations take Go's compound form (`1m30s`, `1h2m`, `2m500ms`).
250
+ - While a create or update runs, its names (the container, `-next-`, `-old-`, the ids) are locked: actions, `rm`, `exec` (and the exec socket), stack actions and prune answer 409 `container <name> is being updated`. Reading the new container back is part of the swap (a failure restores the old one); a paused container is paused again after a recreate or a restore. If the server stops in the middle of a recreate, the `<name>-next-<hex>` and `<name>-old-<hex>` containers stay for an operator to clean up.
251
+ - Rules found in the second review:
252
+ - A network named `host` (in `networks`, or the host network's id) is `networkMode` host: it needs `allowPrivileged` (400 `networkMode needs the allowPrivileged setting`).
253
+ - `container:` chains are followed up to 5 steps (a chain that is longer counts as powerful); the powers of every container on the way count as the container's own, also for the edit rule.
254
+ - A container that already has any power `allowPrivileged` gates (its own or through a `container:` target) needs the setting for every edit that recreates it (`<first changed field> needs the allowPrivileged setting`); in-place updates stay free.
255
+ - `PUT /admin/containers/:id` itself is checked against the name lock (409 `container <name> is being updated` for the old, new, `-next-` and `-old-` container, by name or id).
256
+ - Rules found in the third review (containers): the existing powers of a container for the edit rule also include `DeviceCgroupRules`, `DeviceRequests`, `UTSMode` host, a `Runtime` other than the default, `CgroupParent`, `GroupAdd` and bind mounts outside `bindMounts`; within one spec no bind may lie inside the source of another read-write bind (400 `bind mount <source> lies inside the read-write bind <other>`).
257
+ - Residual: a container created with a read-write bind of a `bindMounts` folder can swap folders that another stack or container binds inside it, because the plugin cannot see what writers do on the host. List in `bindMounts` only folders whose writers you trust.
258
+ - One container name has at most one running create or update (409 `container <name> is already being updated`); they count towards the 5 running operations.
259
+ - `docker run` / `docker create` options, as the Docker CLI spells them: `--name`, `-p`/`--publish [ip:][public:]private[/proto]`,
260
+ `-P`, `-e`/`--env`, `-l`/`--label`, `-v`/`--volume source:destination[:ro]` (a source starting with `/` is a bind, else a volume;
261
+ a lone destination is an anonymous volume), `--mount type=…,source=…,target=…[,readonly]`, `--tmpfs destination[:size=<n>]`,
262
+ `--network` (repeatable: the first is the mode or the first network), `--network-alias`, `--ip`, `--ip6`, `--dns`, `--dns-search`,
263
+ `--dns-option`, `--add-host`, `--restart policy[:n]`, `-m`/`--memory`, `--memory-reservation`, `--memory-swap`, `--cpus`,
264
+ `--cpu-shares`, `--cpuset-cpus`, `--pids-limit`, `--shm-size`, `--ulimit name=soft[:hard]`, `--health-cmd`, `--health-interval`,
265
+ `--health-timeout`, `--health-start-period`, `--health-retries`, `--no-healthcheck`, `--stop-signal`, `--stop-timeout`, `--init`,
266
+ `--read-only`, `--rm`, `--log-driver`, `--log-opt`, `--sysctl`, `--cap-add`, `--cap-drop`, `--privileged`, `--device`, `--security-opt`,
267
+ `--pid`, `--ipc`, `--userns`, `--cgroupns`, `--platform`, `-w`, `-u`, `-h`, `--domainname`, `--entrypoint` (one word), `-t`, `-i`
268
+ (sets `openStdin`; the terminal does not attach, `docker exec -it` does), `-d` (accepted, always detached) and `--pull missing|always|never`.
269
+ Sizes take `b`, `k`, `m`, `g` (1024-based), durations `ms`, `s`, `m`, `h`. `--env-file` is 400 `--env-file is not supported`; any other
270
+ option is 400 `unknown option <option>`. There are no structured MCP tools for creating or editing (the commands are tools like every command).
271
+
196
272
  ## Compose
197
273
 
198
274
  Stacks can be created, updated and removed from their compose file. This runs the `docker compose` CLI on the machine
@@ -216,6 +292,11 @@ text of `GET /compose`).
216
292
  the temp file over the target: the existing file (it keeps the file's mode; a new file is 0644), or
217
293
  `<first existing root>/<name>/compose.yaml` (the folder is created, and removed again when the write fails). The target and
218
294
  its folder are never links.
295
+ - Rules for the file: after `config --quiet`, `PUT .../compose` and every `up` run `<composeCommand> -p <name> -f <file> config --format json` and check each service like a container spec: `privileged`, `cap_add`, `devices`, `security_opt`, `network_mode`/`pid`/`ipc`/`userns_mode`/`cgroup` `host` need `allowPrivileged` (400 `service <s>: <field> needs the allowPrivileged setting`); `container:` modes and `volumes_from` containers are resolved like references (404 hidden/unknown, 409 protected) and `service:` modes are free; bind sources must be under `bindMounts` or the stack's own folder (400 `service <s>: bind mount <path> is outside the allowed folders`); volumes follow the volume rules above; `container_name` (or the default `<project>-<service>-1`) and labels must not match `hide`/`protect` (409 `service <s>: container <name> would be hidden or protected`). A refused write changes nothing; a refused `up` starts nothing and creates no operation (audited). `stop`, `start` and `down` still work.
296
+ - Second review, compose: more fields need `allowPrivileged` (`device_cgroup_rules`, `uts: host`, `runtime`, `cgroup_parent`, `gpus`, `deploy.resources.reservations.devices`; a compose network named `host` or the host network's id is `network_mode`; a top-level volume with `driver_opts` or a driver other than `local`: 400 `volume <name>: driver options need the allowPrivileged setting`). Top-level `secrets` and `configs` with `file` are bind mounts (400 `secret <name>: file <path> is outside the allowed folders`, `config <name>: ...`). The stack's own folder is a bind root only when the file's real folder is exactly `<root>/<name>` and the host is `local`; a source is resolved with its real path on the server, must exist and stay under the folder (or `bindMounts`). `build`: the context and every `additional_contexts` path must be under the stack's own folder (400 `service <s>: build context <path> is outside the stack folder`; `service:` and `docker-image://` contexts are fine), and `build.ssh`, `build.secrets`, `build.entitlements`, `build.privileged`, `build.network: host` are 400 `service <s>: build.<field> is not allowed` (also with `allowPrivileged`). `volumes_from: container:<x>` is refused when `<x>` has a bind outside the allowed folders or any power the setting gates (400 `service <s>: volumes_from <x> needs the allowPrivileged setting`). Replicas: `<project>-<service>-<n>` for n up to `scale` or `deploy.replicas` (100 at most) are checked against hide and protect.
297
+ - Third review, compose: the file is checked against the keys that are allowed (`compose_rules.py`): top level `name`, `services`, `networks`, `volumes`, `secrets`, `configs` (and inert `x-` extensions; anything else is 400 `<key> is not supported`), the service keys compose's `config` writes for ordinary services, the `build` keys (`cache_from`/`cache_to` only of the registry type) and the `networks`/`volumes` entry keys. Any other service key (`use_api_socket`, `provider`, `models`, `isolation`, `group_add`, future keys, a hook with `privileged: true` reported as `post_start`/`pre_stop`, `deploy.<unlisted>`) is 400 `service <s>: <key> needs the allowPrivileged setting`; `build.<key>` outside the list is 400 `service <s>: build.<key> is not allowed` (also with `allowPrivileged`); a network with `driver_opts` or a driver other than `bridge` is 400 `network <name>: driver options need the allowPrivileged setting`. A second `config --format json --no-env-resolution` (compose 2.24 or newer, else 409 `compose <version> is too old (2.24 or newer)`) keeps `env_file`, `label_file` and `build.dockerfile` as paths: each must resolve under the stack's own folder (400 `service <s>: <key> <path> is outside the stack folder`). The stack folder itself is never a bind source (400 `service <s>: bind mount <source> would expose the stack folder`) and no bind of the stack lies inside another read-write bind of it. A compose error in a 400 is its first line, 300 characters at most.
298
+ - Fourth review, one resolution checked and run: the plugin runs `config --format json --no-env-resolution` once on the stack's file and checks the paths in it (`env_file`, `label_file`, `build.dockerfile`, build contexts); it then inlines what `up` would read again (each `label_file` merged into `labels` and removed, explicit labels win; the Dockerfile read through its real path, 1 MB at most, into `build.dockerfile_inline` with `dockerfile` removed; 400 `service <s>: build.dockerfile <path> is not a file of 1 MB or less`), writes that to a private file and runs `config --format json` on it (`--project-directory=<stack folder> --env-file=/dev/null`: it reads only the env files that were checked), runs every key check on that output and writes it to a second private file: `up` runs exactly that (`--project-name=<name> --file=<second file> --project-directory=<stack folder> --env-file=/dev/null up -d --remove-orphans`), so changing the compose file, `.env`, an env file, a label file, a Dockerfile or an included file after the check changes nothing. Verified with Docker Compose v5.7.1 (parse only): `env_file` paths in the private file are read and merged into `environment`, `labels` and `dockerfile_inline` survive, and the original files are not needed again. Files the plugin reads for a stack (Dockerfile, label files, env files) are opened with `O_NOFOLLOW`, checked on the open file (regular, 1 MB at most), their real path is checked again under the stack folder and against the open file's device and inode, and they are read from that open file. Text put into `dockerfile_inline` and `labels` has every `$` doubled (compose interpolates the private file again and prints the escaped form, which `up` reads once more, so the text arrives literal; verified with `docker compose config`); env files are copied into the private folder and `env_file` points at the copies. The private files live in `<dataDir>/plugin-data/docker/tmp/c-<random>` (0700; files 0600), never the system temporary folder (without a data folder: a fresh 0700 `qcli-docker-<random>` straight under it; a data-folder `tmp` that the server's user does not own is refused), and are removed afterwards.
299
+ - Build contexts, `additional_contexts` and secret/config files must not lie inside a read-write bind source of the stack (400 `service <s>: build context <path> lies inside the read-write bind <outer>`, `secret <name>: file <path> lies inside the read-write bind <outer>`, `config <name>: ...`). Logging: without `allowPrivileged` only the drivers `json-file`, `local`, `journald` and `none` (400 `service <s>: logging driver <driver> needs the allowPrivileged setting`; a spec's `logDriver`: 400 `logDriver <driver> needs the allowPrivileged setting`; kept when the container already has it). Annotations starting `run.oci.` or `io.containerd.`: 400 `service <s>: annotation <key> needs the allowPrivileged setting`. An external compose network, or a spec network (by name or id), whose engine driver is not `bridge` or `overlay` (the built-in `none` excepted): 400 `network <name>: driver <driver> needs the allowPrivileged setting`. A `bindMounts` entry that covers the server's data folder is ignored and logged.
219
300
  - `POST .../up` is an operation of kind `stack-up` (`--project-name=<name> --file=<real path> up -d --remove-orphans`,
220
301
  `--pull always` with `pull`, in the file's folder, killed at `composeTimeoutSeconds`). `file` only serves a stack with no
221
302
  file by the rule. Its `log` holds the last 200 lines of the CLI's output (stdout and stderr merged, ANSI codes stripped,
@@ -251,11 +332,11 @@ The structured provider has no remove or prune tool.
251
332
  server that is not protected) is refused everywhere: routes 403 `the Docker plugin needs a protected server (sign-in);
252
333
  see its allowUnprotected setting`, commands the same text after `Error: `, MCP tools the same error, the exec socket
253
334
  closes 4401 `login required`. The check is one method of the service, `assert_caller`, called once per call.
254
- - `readOnly` refuses every change, including exec. Hidden containers do not exist. Protected containers can be read but
335
+ - `readOnly` refuses every change, including exec and creating or editing containers. Hidden containers do not exist. Protected containers can be read but
255
336
  not changed (actions, rm, exec, prune, stack actions on them).
256
337
  - Every change is recorded in the server's audit log when it has one: event `docker.<object>.<action>`
257
338
  (`docker.container.restart`, `docker.image.pull`, `docker.exec.run`, `docker.exec.session`, `docker.stack.down`,
258
- `docker.volumes.prune`, ...), `target` `docker:<host>/<kind>/<name>`, `properties` `{ host, ... }`; the command of an exec
339
+ `docker.volumes.prune`, `docker.container.create`, `docker.container.update`, ...), `target` `docker:<host>/<kind>/<name>`, `properties` `{ host, ... }`; the command of an exec
259
340
  is recorded, its output is not; failures carry `properties.error`, and so do changes refused by read-only mode or
260
341
  protection (hidden containers do not exist, so they leave no entry).
261
342
  - A protected container, running or not, refuses `stacks down` of its stack whole; with hidden containers in the stack,
@@ -60,6 +60,8 @@ read on every call, so a change applies without a restart, except hosts and TLS
60
60
  | `composeHosts` | string[] | `["local"]` | The hosts compose may change; write, `up`, compose `down` and delete on another host are 409 `compose is not enabled for host <name>` (the Engine API way of `down` for a stack without a file works on any host) |
61
61
  | `composeEnv` | string[] | `[]` | Names of the server's environment variables the compose CLI may see (for `${VAR}` in compose files); names starting with `DOCKER_` or `COMPOSE_` are ignored |
62
62
  | `composeTimeoutSeconds` | number 10-3600 | 900 | Time limit of one compose `up` (`down` has 120 s) |
63
+ | `bindMounts` | string[] | `[]` | Host folders a created or edited container may bind-mount (absolute paths); a bind source must be one of them or lie under one, compared as text after normalizing (`.`, `..`, repeated and trailing `/` removed; a source that climbs above `/` is refused). The folders are on the engine's machine, so the server cannot resolve links there: list only folders whose content the admins control. Empty: 400 `bind mounts are not allowed (see the bindMounts setting)`; outside: 400 `bind mount <source> is outside the allowed folders` |
64
+ | `allowPrivileged` | boolean | false | Allow the settings that give a container power over the host: `privileged`, `capAdd`, `devices`, `securityOpt`, `networkMode`/`pidMode`/`ipcMode`/`usernsMode`/`cgroupnsMode` `host`. Off: 400 `<field> needs the allowPrivileged setting`. An edit keeps a value the container already has; only what it adds is checked |
63
65
  | `allowUnprotected` | boolean | false | Serve callers that are not signed in (a server without the users plugin's protection); off: see the first rule below |
64
66
  | `timeoutSeconds` | number 1-120 | 15 | Timeout of one Engine API call (not of streams, pulls or exec) |
65
67
 
@@ -96,7 +98,7 @@ prefix of at least 3 characters or a name.
96
98
  | `GET /containers?all=&stack=`, `/containers/{id}` | read | containers sorted by name; one with its detail (command, masked environment, mounts, networks) |
97
99
  | `GET /containers/{id}/logs?tail=&since=&timestamps=` | read | `{ host, lines }`, oldest first |
98
100
  | `GET /stats?ids=` | read | CPU, memory, network, block I/O and pids (two samples per container) |
99
- | `GET /compose` | read | `{ available, version?, roots, error? }`: whether the compose CLI answers (`version --short`, 5 s, cached 60 s) |
101
+ | `GET /compose` | read | `{ available, version?, roots, error?, bindMounts, allowPrivileged }`: whether the compose CLI answers (`version --short`, 5 s, cached 60 s), and what the container form may offer (the normalized `bindMounts` and `allowPrivileged`) |
100
102
  | `GET /images`, `/stacks`, `/stacks/{name}`, `/volumes[/{name}]`, `/networks[/{id}]` | read | lists and details; a stack has `composeFile` (the path found by the rule) and the state `down` when only its folder exists |
101
103
  | `GET /operations`, `/operations/{id}` | read | the last 50 operations (pulls, stack updates), newest first |
102
104
  | `POST /containers/{id}/start\|stop\|restart\|kill\|pause\|unpause` | manage | `{ ok, container }` |
@@ -104,6 +106,9 @@ prefix of at least 3 characters or a name.
104
106
  | `POST /stacks/{name}/start\|stop\|restart` | manage | `{ ok, results }` per container (a protected one is reported, the rest run) |
105
107
  | `POST /stacks/{name}/pull` | manage | 202 `{ operation }` |
106
108
  | `POST /exec/{id}` `{ command, user?, workdir?, timeoutSeconds? }` | exec | `{ exitCode, stdout, stderr, truncated }` (1 MB per stream; 504 on timeout) |
109
+ | `GET /admin/containers/{id}/spec` | admin | `{ host, spec, stack, editable, reason? }`: the container's configuration as a ContainerSpec (see Creating and editing containers) |
110
+ | `POST /admin/containers` `{ spec, start?, pull? }` | admin | 202 `{ operation }` (kind `container-create`) |
111
+ | `PUT /admin/containers/{id}` `{ spec, pull? }` | admin | 202 `{ operation }` (kind `container-update`): an in-place update or a recreate |
107
112
  | `DELETE /admin/containers/{id}?force=&volumes=`, `POST /admin/containers/prune` | admin | `{ ok }`; `{ removed, reclaimedBytes }` (hidden and protected containers are never pruned) |
108
113
  | `DELETE /admin/images/{id}?force=`, `POST /admin/images/prune` `{ all? }` | admin | `{ ok, untagged, deleted }`; `{ removed, reclaimedBytes }` |
109
114
  | `POST /admin/volumes`, `DELETE /admin/volumes/{name}?force=`, `POST /admin/volumes/prune` | admin | 201 `{ volume }`; `{ ok }`; `{ removed, reclaimedBytes }` |
@@ -150,6 +155,8 @@ printed (the route's answer indented by 2); destructive commands ask first (`--y
150
155
  | `docker stats [container] [--watch]` | read | `--watch` refreshes the table every 2 s |
151
156
  | `docker start\|stop\|restart\|kill\|pause\|unpause <container...>` | manage | one line per container; exit 1 when any failed |
152
157
  | `docker rm <container...> [--force] [--volumes] [--yes]` | admin | asks first |
158
+ | `docker run [options] <image> [command...]`, `docker create [options] <image> [command...]` | admin | creates (and starts, for `run`) a container; the options are the Docker CLI's, before the image, everything after it is the command (see below). A progress block, then `Created <name> (<shortId>), <state>` |
159
+ | `docker update [--restart <policy>[:<n>]] [--memory <size>] [--memory-reservation <size>] [--memory-swap <size>] [--cpus <n>] [--cpu-shares <n>] [--cpuset-cpus <list>] [--pids-limit <n>] <container>` | admin | an in-place change only; removing a limit is refused (edit the container to recreate it) |
153
160
  | `docker exec [options] <container> [<command...>]` | exec | options `-i`, `-t`, `-it`, `--interactive`, `--tty`, `--user`/`-u`, `--workdir`/`-w`, `--timeout <s>`, `--host` go BEFORE the container (as in the docker CLI); everything after the container is the command, flags included, taken from the raw line and split like a shell line: `docker exec web ls -la /`, `docker exec -u root web sh -c "echo a; exit 3"`. Output: stdout, then stderr (warning); the command's exit code |
154
161
  | `docker images`, `docker images prune [--all] [--yes]` | read; admin | |
155
162
  | `docker pull <image>` | manage | progress until done |
@@ -166,6 +173,75 @@ printed (the route's answer indented by 2); destructive commands ask first (`--y
166
173
  | `docker networks create <name> [--driver <d>] [--internal] [--subnet <cidr>]`, `rm <name...> [--yes]`, `prune [--yes]` | admin | |
167
174
  | `docker system info`, `system df`, `system events [--since <1h>] [--follow]` | read | |
168
175
 
176
+ ## Creating and editing containers
177
+
178
+ `docker:admin` only, refused in read-only mode, audited (`docker.container.create`, `docker.container.update`; properties
179
+ `{ host, image, recreated }`, never the spec: its env can hold secrets). Docker cannot change most of a container's
180
+ configuration in place, so an **edit recreates the container under the same name** (its volumes are kept), except for the
181
+ few settings the engine updates in place.
182
+
183
+ **ContainerSpec** (the body's `spec`): `name`, `image` (required; no tag means `:latest`), `command`, `entrypoint` (`[""]`
184
+ clears the image's), `workdir`, `user`, `hostname`, `domainname`, `env` (`NAME=value`, 200 at most), `labels` (100 at most;
185
+ `com.docker.compose.*` is reserved), `tty`, `openStdin`, `ports` (`{ private, public?, ip?, type? }`), `publishAll`, `mounts`
186
+ (`{ type: volume|bind|tmpfs, source?, destination, readOnly?, tmpfsSizeBytes? }`), `networkMode`, `networks`
187
+ (`{ name, aliases?, ipv4Address?, ipv6Address? }`: the first one, or the one `networkMode` names, is used at create, the
188
+ others are connected before the start), `dns`, `dnsSearch`, `dnsOptions`, `extraHosts`, `restartPolicy`, `maxRetries`,
189
+ `memoryBytes` (0 or at least 6 MB), `memoryReservationBytes`, `memorySwapBytes`, `cpus`, `cpuShares`, `cpusetCpus`,
190
+ `pidsLimit`, `shmSizeBytes`, `ulimits`, `healthcheck` (`{ test, intervalSeconds?, timeoutSeconds?, startPeriodSeconds?, retries? }`),
191
+ `stopSignal`, `stopTimeoutSeconds`, `init`, `readOnlyRootfs`, `autoRemove`, `logDriver`, `logOptions`, `sysctls`, `capAdd`,
192
+ `capDrop`, `privileged`, `devices`, `securityOpt`, `pidMode`, `ipcMode`, `usernsMode`, `cgroupnsMode` and `platform` (create
193
+ only). An unknown field is 400 `unknown field <name>`; `null` counts as missing. Nothing but what the spec sets is sent to
194
+ the engine's create call.
195
+
196
+ - `GET /admin/containers/{id}/spec` returns what a person would have written: only the fields that differ from the image's
197
+ or the engine's defaults. Secret-like env values are `••••••`; sending `NAME=••••••` back keeps the container's value
198
+ (a name it does not have: 400 `env <NAME> has no value to keep`). Anonymous volumes come back with their volume name as
199
+ `source`, so an edit keeps their data. `editable` is false with a `reason` for a protected container and for one that
200
+ belongs to a compose stack (`container <name> belongs to stack <stack>; change the stack's compose file`).
201
+ - Create: pull as asked (`pull`: `missing` (default), `always`, `never`: with the image missing it fails `image <image> is not on host <host>`),
202
+ create, connect the other networks, start when `start` (default true). A failed start leaves the created container (as
203
+ `docker run` does): the operation fails with the engine's message and carries `result.container`.
204
+ - The spec of an edit is the whole desired state of the fields a ContainerSpec has: a field left out means the image's or the engine's default (a limit is removed, `command` is the image's), and an explicit `0`, `""`, `false` or `[]` means the same; only settings a spec cannot express are kept from the container. An existing bind mount (same source and destination) is kept without the `bindMounts` check. Health check durations may be fractional seconds (nanoseconds, rounded down).
205
+ - Edit: when only `restartPolicy`, `maxRetries`, `memoryBytes`, `memoryReservationBytes`, `memorySwapBytes`, `cpus`,
206
+ `cpuShares`, `cpusetCpus` and `pidsLimit` differ, the engine's update call runs (no restart; message `updated in place`).
207
+ Otherwise the container is recreated: the new one is made as `<name>-next-<6 hex>` from the old one's whole configuration with
208
+ the spec's fields applied (what the spec does not express, set by another tool, is kept), its other networks connected,
209
+ the old one stopped when it was running and renamed `<name>-old-<6 hex>`, the new one renamed and started, the old one
210
+ removed (without its volumes). A failure after the old one was stopped or renamed puts it back (the new one is removed,
211
+ the old one renamed back and started when it was running) and the operation fails with `<engine message>; the old container was restored`.
212
+ The id changes; `result.container` is the new container (the restored one after a restore).
213
+ - Checked before the operation starts (the answer is the error, no operation): the spec (400), `bindMounts` and
214
+ `allowPrivileged` (400), a name or labels that a `hide` or `protect` pattern would match (409 `container <name> would be hidden or protected`), an existing container
215
+ with the new name (409 `a container named <name> already exists`), an unknown network (404 `no such network: <name>`), a hidden (404), protected (409) or stack (409) container being edited.
216
+ - Rules found in review (create and edit alike):
217
+ - `autoRemove`: an edit that needs a recreate is 409 `container <name> removes itself when stopped (autoRemove); it cannot be recreated` (the engine would remove the old container when it stops); an in-place edit still works.
218
+ - `networkMode`, `pidMode` and `ipcMode` of the form `container:<x>` resolve `<x>` through the visible list: hidden or unknown is 404 `no such container: <x>`, protected 409 `container <name> is protected`; a target that is privileged or uses a host namespace needs `allowPrivileged`. A value the container already has is kept on an edit.
219
+ - A volume used by a hidden container is 404 `no such volume: <source>`; one used by a protected container may only be mounted read-only (409 `volume <source> belongs to protected container <name>`). Mounts a container already has are kept on an edit.
220
+ - A container that already has `allowPrivileged` fields needs the setting to change its `image`, `command`, `entrypoint` or `user` (400 `<field> needs the allowPrivileged setting`).
221
+ - A create refuses `NAME=••••••` (400 `env <NAME> has no value to keep`); an edit keeps the value.
222
+ - The spec read leaves out `hostname` and `domainname` when the network mode is `host` or `container:*`. `stopTimeoutSeconds` is 0 to 2147483647; durations take Go's compound form (`1m30s`, `1h2m`, `2m500ms`).
223
+ - While a create or update runs, its names (the container, `-next-`, `-old-`, the ids) are locked: actions, `rm`, `exec` (and the exec socket), stack actions and prune answer 409 `container <name> is being updated`. Reading the new container back is part of the swap (a failure restores the old one); a paused container is paused again after a recreate or a restore. If the server stops in the middle of a recreate, the `<name>-next-<hex>` and `<name>-old-<hex>` containers stay for an operator to clean up.
224
+ - Rules found in the second review:
225
+ - A network named `host` (in `networks`, or the host network's id) is `networkMode` host: it needs `allowPrivileged` (400 `networkMode needs the allowPrivileged setting`).
226
+ - `container:` chains are followed up to 5 steps (a chain that is longer counts as powerful); the powers of every container on the way count as the container's own, also for the edit rule.
227
+ - A container that already has any power `allowPrivileged` gates (its own or through a `container:` target) needs the setting for every edit that recreates it (`<first changed field> needs the allowPrivileged setting`); in-place updates stay free.
228
+ - `PUT /admin/containers/:id` itself is checked against the name lock (409 `container <name> is being updated` for the old, new, `-next-` and `-old-` container, by name or id).
229
+ - Rules found in the third review (containers): the existing powers of a container for the edit rule also include `DeviceCgroupRules`, `DeviceRequests`, `UTSMode` host, a `Runtime` other than the default, `CgroupParent`, `GroupAdd` and bind mounts outside `bindMounts`; within one spec no bind may lie inside the source of another read-write bind (400 `bind mount <source> lies inside the read-write bind <other>`).
230
+ - Residual: a container created with a read-write bind of a `bindMounts` folder can swap folders that another stack or container binds inside it, because the plugin cannot see what writers do on the host. List in `bindMounts` only folders whose writers you trust.
231
+ - One container name has at most one running create or update (409 `container <name> is already being updated`); they count towards the 5 running operations.
232
+ - `docker run` / `docker create` options, as the Docker CLI spells them: `--name`, `-p`/`--publish [ip:][public:]private[/proto]`,
233
+ `-P`, `-e`/`--env`, `-l`/`--label`, `-v`/`--volume source:destination[:ro]` (a source starting with `/` is a bind, else a volume;
234
+ a lone destination is an anonymous volume), `--mount type=…,source=…,target=…[,readonly]`, `--tmpfs destination[:size=<n>]`,
235
+ `--network` (repeatable: the first is the mode or the first network), `--network-alias`, `--ip`, `--ip6`, `--dns`, `--dns-search`,
236
+ `--dns-option`, `--add-host`, `--restart policy[:n]`, `-m`/`--memory`, `--memory-reservation`, `--memory-swap`, `--cpus`,
237
+ `--cpu-shares`, `--cpuset-cpus`, `--pids-limit`, `--shm-size`, `--ulimit name=soft[:hard]`, `--health-cmd`, `--health-interval`,
238
+ `--health-timeout`, `--health-start-period`, `--health-retries`, `--no-healthcheck`, `--stop-signal`, `--stop-timeout`, `--init`,
239
+ `--read-only`, `--rm`, `--log-driver`, `--log-opt`, `--sysctl`, `--cap-add`, `--cap-drop`, `--privileged`, `--device`, `--security-opt`,
240
+ `--pid`, `--ipc`, `--userns`, `--cgroupns`, `--platform`, `-w`, `-u`, `-h`, `--domainname`, `--entrypoint` (one word), `-t`, `-i`
241
+ (sets `openStdin`; the terminal does not attach, `docker exec -it` does), `-d` (accepted, always detached) and `--pull missing|always|never`.
242
+ Sizes take `b`, `k`, `m`, `g` (1024-based), durations `ms`, `s`, `m`, `h`. `--env-file` is 400 `--env-file is not supported`; any other
243
+ option is 400 `unknown option <option>`. There are no structured MCP tools for creating or editing (the commands are tools like every command).
244
+
169
245
  ## Compose
170
246
 
171
247
  Stacks can be created, updated and removed from their compose file. This runs the `docker compose` CLI on the machine
@@ -189,6 +265,11 @@ text of `GET /compose`).
189
265
  the temp file over the target: the existing file (it keeps the file's mode; a new file is 0644), or
190
266
  `<first existing root>/<name>/compose.yaml` (the folder is created, and removed again when the write fails). The target and
191
267
  its folder are never links.
268
+ - Rules for the file: after `config --quiet`, `PUT .../compose` and every `up` run `<composeCommand> -p <name> -f <file> config --format json` and check each service like a container spec: `privileged`, `cap_add`, `devices`, `security_opt`, `network_mode`/`pid`/`ipc`/`userns_mode`/`cgroup` `host` need `allowPrivileged` (400 `service <s>: <field> needs the allowPrivileged setting`); `container:` modes and `volumes_from` containers are resolved like references (404 hidden/unknown, 409 protected) and `service:` modes are free; bind sources must be under `bindMounts` or the stack's own folder (400 `service <s>: bind mount <path> is outside the allowed folders`); volumes follow the volume rules above; `container_name` (or the default `<project>-<service>-1`) and labels must not match `hide`/`protect` (409 `service <s>: container <name> would be hidden or protected`). A refused write changes nothing; a refused `up` starts nothing and creates no operation (audited). `stop`, `start` and `down` still work.
269
+ - Second review, compose: more fields need `allowPrivileged` (`device_cgroup_rules`, `uts: host`, `runtime`, `cgroup_parent`, `gpus`, `deploy.resources.reservations.devices`; a compose network named `host` or the host network's id is `network_mode`; a top-level volume with `driver_opts` or a driver other than `local`: 400 `volume <name>: driver options need the allowPrivileged setting`). Top-level `secrets` and `configs` with `file` are bind mounts (400 `secret <name>: file <path> is outside the allowed folders`, `config <name>: ...`). The stack's own folder is a bind root only when the file's real folder is exactly `<root>/<name>` and the host is `local`; a source is resolved with its real path on the server, must exist and stay under the folder (or `bindMounts`). `build`: the context and every `additional_contexts` path must be under the stack's own folder (400 `service <s>: build context <path> is outside the stack folder`; `service:` and `docker-image://` contexts are fine), and `build.ssh`, `build.secrets`, `build.entitlements`, `build.privileged`, `build.network: host` are 400 `service <s>: build.<field> is not allowed` (also with `allowPrivileged`). `volumes_from: container:<x>` is refused when `<x>` has a bind outside the allowed folders or any power the setting gates (400 `service <s>: volumes_from <x> needs the allowPrivileged setting`). Replicas: `<project>-<service>-<n>` for n up to `scale` or `deploy.replicas` (100 at most) are checked against hide and protect.
270
+ - Third review, compose: the file is checked against the keys that are allowed (`compose_rules.py`): top level `name`, `services`, `networks`, `volumes`, `secrets`, `configs` (and inert `x-` extensions; anything else is 400 `<key> is not supported`), the service keys compose's `config` writes for ordinary services, the `build` keys (`cache_from`/`cache_to` only of the registry type) and the `networks`/`volumes` entry keys. Any other service key (`use_api_socket`, `provider`, `models`, `isolation`, `group_add`, future keys, a hook with `privileged: true` reported as `post_start`/`pre_stop`, `deploy.<unlisted>`) is 400 `service <s>: <key> needs the allowPrivileged setting`; `build.<key>` outside the list is 400 `service <s>: build.<key> is not allowed` (also with `allowPrivileged`); a network with `driver_opts` or a driver other than `bridge` is 400 `network <name>: driver options need the allowPrivileged setting`. A second `config --format json --no-env-resolution` (compose 2.24 or newer, else 409 `compose <version> is too old (2.24 or newer)`) keeps `env_file`, `label_file` and `build.dockerfile` as paths: each must resolve under the stack's own folder (400 `service <s>: <key> <path> is outside the stack folder`). The stack folder itself is never a bind source (400 `service <s>: bind mount <source> would expose the stack folder`) and no bind of the stack lies inside another read-write bind of it. A compose error in a 400 is its first line, 300 characters at most.
271
+ - Fourth review, one resolution checked and run: the plugin runs `config --format json --no-env-resolution` once on the stack's file and checks the paths in it (`env_file`, `label_file`, `build.dockerfile`, build contexts); it then inlines what `up` would read again (each `label_file` merged into `labels` and removed, explicit labels win; the Dockerfile read through its real path, 1 MB at most, into `build.dockerfile_inline` with `dockerfile` removed; 400 `service <s>: build.dockerfile <path> is not a file of 1 MB or less`), writes that to a private file and runs `config --format json` on it (`--project-directory=<stack folder> --env-file=/dev/null`: it reads only the env files that were checked), runs every key check on that output and writes it to a second private file: `up` runs exactly that (`--project-name=<name> --file=<second file> --project-directory=<stack folder> --env-file=/dev/null up -d --remove-orphans`), so changing the compose file, `.env`, an env file, a label file, a Dockerfile or an included file after the check changes nothing. Verified with Docker Compose v5.7.1 (parse only): `env_file` paths in the private file are read and merged into `environment`, `labels` and `dockerfile_inline` survive, and the original files are not needed again. Files the plugin reads for a stack (Dockerfile, label files, env files) are opened with `O_NOFOLLOW`, checked on the open file (regular, 1 MB at most), their real path is checked again under the stack folder and against the open file's device and inode, and they are read from that open file. Text put into `dockerfile_inline` and `labels` has every `$` doubled (compose interpolates the private file again and prints the escaped form, which `up` reads once more, so the text arrives literal; verified with `docker compose config`); env files are copied into the private folder and `env_file` points at the copies. The private files live in `<dataDir>/plugin-data/docker/tmp/c-<random>` (0700; files 0600), never the system temporary folder (without a data folder: a fresh 0700 `qcli-docker-<random>` straight under it; a data-folder `tmp` that the server's user does not own is refused), and are removed afterwards.
272
+ - Build contexts, `additional_contexts` and secret/config files must not lie inside a read-write bind source of the stack (400 `service <s>: build context <path> lies inside the read-write bind <outer>`, `secret <name>: file <path> lies inside the read-write bind <outer>`, `config <name>: ...`). Logging: without `allowPrivileged` only the drivers `json-file`, `local`, `journald` and `none` (400 `service <s>: logging driver <driver> needs the allowPrivileged setting`; a spec's `logDriver`: 400 `logDriver <driver> needs the allowPrivileged setting`; kept when the container already has it). Annotations starting `run.oci.` or `io.containerd.`: 400 `service <s>: annotation <key> needs the allowPrivileged setting`. An external compose network, or a spec network (by name or id), whose engine driver is not `bridge` or `overlay` (the built-in `none` excepted): 400 `network <name>: driver <driver> needs the allowPrivileged setting`. A `bindMounts` entry that covers the server's data folder is ignored and logged.
192
273
  - `POST .../up` is an operation of kind `stack-up` (`--project-name=<name> --file=<real path> up -d --remove-orphans`,
193
274
  `--pull always` with `pull`, in the file's folder, killed at `composeTimeoutSeconds`). `file` only serves a stack with no
194
275
  file by the rule. Its `log` holds the last 200 lines of the CLI's output (stdout and stderr merged, ANSI codes stripped,
@@ -224,11 +305,11 @@ The structured provider has no remove or prune tool.
224
305
  server that is not protected) is refused everywhere: routes 403 `the Docker plugin needs a protected server (sign-in);
225
306
  see its allowUnprotected setting`, commands the same text after `Error: `, MCP tools the same error, the exec socket
226
307
  closes 4401 `login required`. The check is one method of the service, `assert_caller`, called once per call.
227
- - `readOnly` refuses every change, including exec. Hidden containers do not exist. Protected containers can be read but
308
+ - `readOnly` refuses every change, including exec and creating or editing containers. Hidden containers do not exist. Protected containers can be read but
228
309
  not changed (actions, rm, exec, prune, stack actions on them).
229
310
  - Every change is recorded in the server's audit log when it has one: event `docker.<object>.<action>`
230
311
  (`docker.container.restart`, `docker.image.pull`, `docker.exec.run`, `docker.exec.session`, `docker.stack.down`,
231
- `docker.volumes.prune`, ...), `target` `docker:<host>/<kind>/<name>`, `properties` `{ host, ... }`; the command of an exec
312
+ `docker.volumes.prune`, `docker.container.create`, `docker.container.update`, ...), `target` `docker:<host>/<kind>/<name>`, `properties` `{ host, ... }`; the command of an exec
232
313
  is recorded, its output is not; failures carry `properties.error`, and so do changes refused by read-only mode or
233
314
  protection (hidden containers do not exist, so they leave no entry).
234
315
  - A protected container, running or not, refuses `stacks down` of its stack whole; with hidden containers in the stack,
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "qodalis-cli-server-plugin-docker"
7
- version = "1.0.0b39"
7
+ version = "1.0.0b40"
8
8
  description = "Docker containers, images, stacks, volumes and networks plugin for Qodalis CLI servers: commands, API, MCP, exec socket and Console page"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -37,7 +37,7 @@ dependencies = [
37
37
  [project.optional-dependencies]
38
38
  # a protected server: the exec socket ends a session when its user signs out or loses docker:exec, which needs the
39
39
  # users plugin's socket_access_state (a session that cannot be supervised is refused)
40
- users = ["qodalis-cli-server-plugin-users>=1.0.0b39"]
40
+ users = ["qodalis-cli-server-plugin-users>=1.0.0b40"]
41
41
 
42
42
  [project.entry-points."qodalis_cli.plugins"]
43
43
  docker = "qodalis_cli_docker.plugin:create_plugin"
@@ -6,10 +6,18 @@ __plugin_icon__ = "🐳"
6
6
 
7
7
  from .builder import DOCKER_PERMISSION_ENTRIES, CliDockerBuilder, CliDockerPlugin
8
8
  from .commands import DockerModule
9
+ from .containers import (
10
+ IN_PLACE_FIELDS, bind_allowed, canonical_spec, changed_fields, check_bind_mounts, check_privileged, compose_source_allowed, compose_source_verdict, container_mode_ref,
11
+ has_bind_outside, has_gated_powers, nested_bind, host_network_named, map_spec, mask_spec, normalize_host_path, privileged_fields, resolve_masked, spec_from_inspect,
12
+ uses_host_power, validate_spec,
13
+ )
9
14
  from .console_page import DOCKER_CONSOLE_PAGE, DOCKER_CONSOLE_PREFIX
10
15
  from .controller import DOCKER_ADMIN, DOCKER_EXEC, DOCKER_MANAGE, DOCKER_PREFIX, DOCKER_READ, create_docker_router
11
16
  from .engine import DockerError, DockerHostConfig, EngineClient, parse_endpoint
12
17
  from .exec_socket import EXEC_SOCKET_PATH, create_exec_handler
18
+ from .run_options import (
19
+ parse_duration, parse_mount, parse_options, parse_publish, parse_restart, parse_size, parse_volume, words_after_verb,
20
+ )
13
21
  from .service import UNPROTECTED_TEXT, DockerCaller, DockerService, read_compose_file
14
22
  from .shapes import container_name
15
23
  from .settings import DockerSettings, docker_settings, read_docker_settings
@@ -34,11 +42,40 @@ __all__ = [
34
42
  "DockerService",
35
43
  "DockerSettings",
36
44
  "EngineClient",
45
+ "IN_PLACE_FIELDS",
46
+ "bind_allowed",
47
+ "canonical_spec",
48
+ "changed_fields",
49
+ "check_bind_mounts",
50
+ "check_privileged",
51
+ "compose_source_allowed",
52
+ "compose_source_verdict",
53
+ "container_mode_ref",
37
54
  "container_name",
38
55
  "create_docker_router",
39
56
  "create_exec_handler",
40
57
  "docker_settings",
58
+ "has_bind_outside",
59
+ "has_gated_powers",
60
+ "host_network_named",
61
+ "map_spec",
62
+ "mask_spec",
63
+ "nested_bind",
64
+ "normalize_host_path",
65
+ "parse_duration",
41
66
  "parse_endpoint",
67
+ "parse_mount",
68
+ "parse_options",
69
+ "parse_publish",
70
+ "parse_restart",
71
+ "parse_size",
72
+ "parse_volume",
73
+ "privileged_fields",
42
74
  "read_compose_file",
43
75
  "read_docker_settings",
76
+ "resolve_masked",
77
+ "spec_from_inspect",
78
+ "uses_host_power",
79
+ "validate_spec",
80
+ "words_after_verb",
44
81
  ]
@@ -120,6 +120,10 @@ class CliDockerBuilder:
120
120
  self._stats_gap: Optional[float] = None
121
121
  self._now: Optional[Callable[[], datetime]] = None
122
122
  self._new_id: Optional[Callable[[], str]] = None
123
+ self._suffix: Optional[Callable[[], str]] = None
124
+ self._progress_tick: Optional[float] = None
125
+ self._data_dir: Optional[str] = None
126
+ self._server_data_dir: Optional[str] = None
123
127
  self._pull_silence: Optional[float] = None
124
128
  self._compose_timeout: Optional[float] = None
125
129
  self._compose_down_timeout: Optional[float] = None
@@ -155,12 +159,22 @@ class CliDockerBuilder:
155
159
  self, *, stats_gap_seconds: Optional[float] = None, now: Optional[Callable[[], datetime]] = None,
156
160
  new_id: Optional[Callable[[], str]] = None, pull_silence_seconds: Optional[float] = None,
157
161
  compose_timeout_seconds: Optional[float] = None, compose_down_timeout_seconds: Optional[float] = None,
158
- exec_check_interval_seconds: Optional[float] = None,
162
+ exec_check_interval_seconds: Optional[float] = None, suffix: Optional[Callable[[], str]] = None,
163
+ progress_tick_seconds: Optional[float] = None,
159
164
  ) -> "CliDockerBuilder":
160
- """Tests: the pause between the two stats samples, the clock, the operation ids and how a compose file is read."""
165
+ """Tests: the pause between the two stats samples, the clock, the operation ids, the hex of the temporary names of a recreate and how a compose file is read."""
161
166
  self._stats_gap, self._now, self._new_id, self._pull_silence = stats_gap_seconds, now, new_id, pull_silence_seconds
162
167
  self._compose_timeout, self._compose_down_timeout = compose_timeout_seconds, compose_down_timeout_seconds
163
168
  self._exec_check_interval = exec_check_interval_seconds
169
+ self._suffix = suffix
170
+ self._progress_tick = progress_tick_seconds
171
+ return self
172
+
173
+ def set_data_dirs(self, data_dir: str, server_data_dir: Optional[str] = None) -> "CliDockerBuilder":
174
+ """The plugin's own data folder (``context.data_dir``: the private compose files live under ``tmp/``) and the server's
175
+ (``context.server_data_dir``: a ``bindMounts`` entry that covers it is ignored)."""
176
+ self._data_dir = data_dir
177
+ self._server_data_dir = server_data_dir
164
178
  return self
165
179
 
166
180
  def build(self) -> CliDockerPlugin:
@@ -174,7 +188,8 @@ class CliDockerBuilder:
174
188
  service = DockerService(
175
189
  self._settings, audit=self._audit, publish=publish, log=self._logger, now=self._now, new_id=self._new_id,
176
190
  stats_gap_seconds=self._stats_gap, pull_silence_seconds=self._pull_silence,
177
- compose_timeout_seconds=self._compose_timeout, compose_down_timeout_seconds=self._compose_down_timeout,
191
+ compose_timeout_seconds=self._compose_timeout, compose_down_timeout_seconds=self._compose_down_timeout, suffix=self._suffix,
192
+ progress_tick_seconds=self._progress_tick, data_dir=self._data_dir, server_data_dir=self._server_data_dir,
178
193
  )
179
194
  page = docker_page(self._console_dir)
180
195
  plugin = CliDockerPlugin(