Skip to content

Commit 3898ea9

Browse files
committed
docs(docker-integration): update label tables for clarity and add CLI scripts section
1 parent 6a38f9c commit 3898ea9

1 file changed

Lines changed: 95 additions & 7 deletions

File tree

docs/advanced/docker-integration.md

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Unraid uses specific Docker labels to integrate containers with the WebUI. Conta
1818
### Standard Labels
1919

2020
| Label | Description | Example |
21-
|-------|-------------|---------|
21+
| ----- | ----------- | ------- |
2222
| `net.unraid.docker.managed` | Indicates management source | `composeman`, `dockerman` |
2323
| `net.unraid.docker.icon` | URL to container icon | `https://example.com/icon.png` |
2424
| `net.unraid.docker.webui` | URL to container's web interface | `http://[IP]:[PORT:8080]/` |
@@ -188,7 +188,7 @@ Unraid® provides a built-in `openTerminal()` JavaScript function for opening co
188188
The global `openTerminal(tag, name, more)` function is defined in Unraid's core JavaScript (HeadInlineJS.php) and is available on all pages.
189189

190190
| Parameter | Description | Values |
191-
|-----------|-------------|--------|
191+
| --------- | ----------- | ------ |
192192
| `tag` | Terminal type | `'docker'` for containers, `'ttyd'` or `'syslog'` for system |
193193
| `name` | Container name | Must match Docker container name exactly |
194194
| `more` | Shell or log flag | Shell command (e.g., `'bash'`, `'sh'`) or `'.log'` for logs |
@@ -356,11 +356,12 @@ if ($status === null) {
356356

357357
Unraid stores update check results in a JSON file to avoid repeated registry queries:
358358

359-
```
359+
```path
360360
/var/lib/docker/unraid-update-status.json
361361
```
362362

363363
Structure:
364+
364365
```json
365366
{
366367
"library/nginx:latest": {
@@ -401,6 +402,94 @@ if (isset($updateStatusData[$image])) {
401402
?>
402403
```
403404

405+
## Docker Manager CLI Scripts (dynamix.docker.manager)
406+
407+
Unraid's Docker Manager plugin exposes several command-line scripts under `/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/`.
408+
Some of these are useful for automation and background jobs.
409+
410+
- `/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker` : wrapper around `docker` command
411+
- `/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate` : plugin update/notification sweep
412+
- `/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/update_container` : update a specific existing container from its template
413+
414+
### Confirmed commands from Unraid community (Squid, Discord screenshot reference)
415+
416+
Execute the Docker Manager update runner (check templates and status):
417+
418+
```bash
419+
/usr/bin/php -q /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate check
420+
```
421+
422+
Update a specific installed Docker template/container (template name as shown in Docker Manager):
423+
424+
```bash
425+
/usr/bin/php -q /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/update_container "<container_name>"
426+
```
427+
428+
- This is the same mechanism used by the WebUI to apply template updates while preserving runtime state.
429+
- Pass a `*`-delimited list to update multiple templates in one invocation.
430+
431+
### Direct template-to-docker command helper (forum reference)
432+
433+
A useful approach in this thread is to convert DockerMan XML templates directly into a `docker run` command using `xmlToCommand()`. This shows how to reproduce Docker Manager behavior from CLI by taking the saved container template and creating a runtime container with the same config.
434+
435+
```php
436+
#!/usr/bin/php
437+
<?php
438+
$docroot = "/usr/local/emhttp";
439+
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
440+
$var = parse_ini_file('/var/local/emhttp/var.ini');
441+
$cfg = parse_ini_file('/boot/config/docker.cfg');
442+
$driver = DockerUtil::driver();
443+
$custom = DockerUtil::custom();
444+
$subnet = DockerUtil::network($custom);
445+
$opts = xmlToCommand($argv[1]);
446+
$cmd = str_replace("create ","run -d ",$opts[0]);
447+
passthru($cmd);
448+
?>
449+
```
450+
451+
- Example usage:
452+
- `php /path/to/runxml.php /boot/config/plugins/dockerMan/templates-user/<your-template>.xml`
453+
- The script resolves volume/env/network/label settings and starts the container in detached mode.
454+
455+
- This concept is explicitly outlined in the Unraid forum post:
456+
- [https://forums.unraid.net/topic/40016-start-docker-template-via-command-line/#findComment-1022006](https://forums.unraid.net/topic/40016-start-docker-template-via-command-line/#findComment-1022006)
457+
458+
### Example: force an update to nginx-runner from a cron job
459+
460+
```bash
461+
*/30 * * * * /usr/bin/php -q /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/update_container "nginx" >> /var/log/docker_update.log 2>&1
462+
```
463+
464+
### Notes
465+
466+
- The script expects the container template name, not the raw Docker container ID.
467+
- Run as root or from `sudo` context on Unraid.
468+
- If your container is running, the script stops it, recreates it from the template, then restarts it (depending on previous state).
469+
470+
### Related script
471+
472+
- `/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker_rm` : remove container by name (script invoked by Docker Manager UI)
473+
474+
### Advanced automation
475+
476+
From plugin PHP code, you can call these scripts with `exec()`/`shell_exec()` and read stdout exit codes for process control.
477+
478+
```php
479+
exec("/usr/bin/php -q /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate check 2>&1", $output, $retval);
480+
if ($retval !== 0) {
481+
error_log("dockerupdate failed: " . implode("\n", $output));
482+
}
483+
```
484+
485+
### Security
486+
487+
These scripts run as root and are not protected by CSRF; do not expose them directly over HTTP without proper access control.
488+
489+
### Caveat
490+
491+
This behavior is taken from community discussion (Unraid forum/Discord) and confirmed by `dynamix.docker.manager` source code in `update_container`.
492+
404493
### Handling Pinned Images (SHA256 Digests)
405494

406495
Some users pin images to specific versions using SHA256 digests in their compose files:
@@ -412,6 +501,7 @@ services:
412501
```
413502

414503
These pinned images should **not** be checked for updates because:
504+
415505
- The user explicitly wants that exact version
416506
- Registry checks return the latest tag digest, not the pinned digest
417507
- Comparing would always show a false "update available"
@@ -461,20 +551,19 @@ if ($pinned) {
461551
### Common Update Check Issues
462552

463553
| Issue | Cause | Solution |
464-
|-------|-------|----------|
554+
| ----- | ----- | -------- |
465555
| Always shows "update available" after pull | Cached local SHA is stale | Clear `local` field before `reloadUpdateStatus()` |
466556
| Image not found in status file | Image name format mismatch | Use `DockerUtil::ensureImageTag()` to normalize |
467557
| Pinned image shows "not checked" | `@sha256:` suffix confuses the check | Detect pinned images and skip update check |
468558
| Official images not matching | Missing `library/` prefix | `ensureImageTag()` adds it automatically |
469-
```
470559

471560
## Unraid Docker Integration
472561

473562
### Reading Docker Configuration
474563

475564
Unraid stores Docker configuration in specific locations:
476565

477-
```
566+
```paths
478567
/boot/config/docker.cfg # Docker settings
479568
/var/lib/docker/ # Docker data (if on array)
480569
/boot/config/plugins/dockerMan/ # Docker templates
@@ -688,7 +777,6 @@ function normalizeImageForUpdateCheck($image) {
688777

689778
{: .note }
690779
> Before normalizing, check if the image is pinned using `isImagePinned()` (see [Update Checking](#handling-pinned-images-sha256-digests)). Pinned images should display their pinned status rather than being checked for updates.
691-
```
692780

693781
### General Guidelines
694782

0 commit comments

Comments
 (0)