Skip to content

Keep Unraid's stored Docker order equal to the folder view, so the order survives without the plugin - #135

Open
luuvasara wants to merge 1 commit into
alexphillips-dev:devfrom
luuvasara:feat/native-docker-order
Open

luuvasara wants to merge 1 commit into
alexphillips-dev:devfrom
luuvasara:feat/native-docker-order

Conversation

@luuvasara

@luuvasara luuvasara commented Nov 16, 2026 •

Copy link
Copy Markdown

Related pull requests

Summary

FolderView Plus writes the order it shows into Unraid's own stored Docker order, /boot/config/plugins/dockerMan/userprefs.cfg. Each folder is written as one contiguous run: the folder-<id> entry, its members in folder order, then its child folders. After the folders come the containers outside folders, in Unraid's order. The plugin then only groups an order that Unraid holds. Removing the plugin, or turning folders off, leaves the containers in the same order as one flat list.

The principle: Unraid owns the order, FolderView Plus only groups it

The container order is Unraid's. It is the start order (Unraid starts containers one by one in the order of its autostart file, which follows userprefs.cfg: https://github.com/unraid/webgui/blob/99e39027fbd50cf8c3768da0464bdd8de754a7f7/etc/rc.d/rc.docker#L712-L736), and it has to be right with or without any plugin. That is not a preference: a dependency has to start before and stop after what needs it, the rule systemd, Docker Compose and Kubernetes apply. Sources and the failures a wrong order causes are in unraid/webgui#2844. A folder is a group within that order, not a second order. Example data:

Where Order shown
Unraid, stored order mariadb, nextcloud, plex, sonarr, radarr
FolderView Plus Cloud [mariadb, nextcloud], Media [plex, sonarr, radarr]
Drag sonarr above plex in Media Cloud [mariadb, nextcloud], Media [sonarr, plex, radarr]
Stored order after that drag folder-Cloud, mariadb, nextcloud, folder-Media, sonarr, plex, radarr
Plugin removed mariadb, nextcloud, sonarr, plex, radarr

When the order inside a folder changes, the stored order changes the same way. Without the folders, the result is the same order. Unraid ignores the folder-… lines because they are not container names.

Why: what happens today

What changes

  • syncNativeDockerOrder() in lib.docker-order.php builds the order shown on the tab: folders first, then the rest in Unraid's order. It writes that to userprefs.cfg in Unraid's own format (0="name" lines). It runs:
    • from syncContainerOrder('docker'), in every start-order mode including "unmanaged";
    • once when the Docker page is first drawn;
    • again for every new set of containers without a stored position.
  • Writes nothing:
    • when there are no folders and Unraid has no stored order (containers then stay in name order, as in Unraid);
    • when the container list could not be read;
    • when the order is already equal.
  • New containers go last, oldest first (Docker's creation time; name order on ties). An app is set up after the database it needs, so the database is older or already listed and starts first. This is the same rule as the Unraid change below, so both give the same result.
  • Locking: it takes the same lock as Unraid (/var/lock/docker-userprefs.lock), so a drag on the Docker tab and this sync cannot overwrite each other.
  • Allowed write path: /boot/config/plugins/dockerMan is added to the allowed write paths in lib.filesystem-security.php, for userprefs.cfg only.
  • Reload: docker.js asks the server to sync and reloads the list only when the file was actually written.

How it fits with Unraid

A matching change for Unraid (unraid/webgui#2844) makes Unraid keep one stored order. It gives every new container a position at the end, and makes the Docker tab, Dashboard and autostart read it the same way. It takes the same lock.

Merged Result
Neither Today's behaviour
This PR only The order with folders is stored natively and survives removing the plugin; new containers are added by this plugin
Unraid PR only Unraid's order is complete; folders are drawn on top as now
Both Unraid registers new containers, this plugin groups them; the same order with or without the plugin

None of these combinations is worse than today, so either PR can be merged first.

Testing

Tested on an Unraid 7.4 test server with Unraid unpatched and patched:

  • A folder saved, then dragged: the stored order matches the tab, and the Dashboard tile matches.
  • A container renamed and its image changed: it keeps its place.
  • Plugin uninstalled: the Docker tab shows the same order without the folders.
  • Two containers created between syncs, named in reverse of creation: stored oldest first.
  • The plugin's own config files are unchanged.

Screenshots

The order with and without FolderView Plus (Unraid 7.4 test server, example containers ord-*):

With FolderView Plus After removing the plugin
Docker tab with a FolderView Plus folder Docker tab after removing FolderView Plus

Left: the folder ord-folder holds ord-m, ord-new2 and ord-new3, between ord-renamed and plex. Right: the same server after removing the plugin: ord-z, ord-renamed, ord-m, ord-new2, ord-new3, plex. The folder is gone and the order stays. These are from an earlier test round, where a folder kept the place it was dragged to; the final version puts folders first, as FolderView Plus draws them.

Folders first, and the Dashboard agrees (previous version of this patch; the last change, new containers oldest first, does not affect what these show):

Docker tab Dashboard tile
Docker tab with the folder first Dashboard Docker tile in the same order

The folder ord-fa comes first, then ord-b3, plex, bazarr, emby, nginx… The Dashboard tile, which reads Unraid's stored order, shows the same sequence.

This change was written with the help of frontier AI. I reviewed and tested it.

syncNativeDockerOrder() writes the order the Docker tab shows (folders first, each folder as one run, then the rest in Unraid's order) to dockerMan/userprefs.cfg in Unraid's format, under Unraid's lock. New containers go last, oldest first. Nothing is written when the order is already equal, the list can't be read, or there are no folders and no stored order. Removing the plugin keeps the same order as a flat list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant