Skip to content

fix: preserve named volume access mode in compose randomize transform#4819

Open
tanaymishra wants to merge 1 commit into
Dokploy:canaryfrom
tanaymishra:fix/compose-volume-preserve-mode
Open

fix: preserve named volume access mode in compose randomize transform#4819
tanaymishra wants to merge 1 commit into
Dokploy:canaryfrom
tanaymishra:fix/compose-volume-preserve-mode

Conversation

@tanaymishra

Copy link
Copy Markdown
Contributor

What is this PR about?

When a Compose service is deployed with "Randomize" or "Isolated Deployment" (with volume isolation), Dokploy appends a suffix to volume names. The transform split each short-syntax volume mount on ":" and kept only the name and path, which silently dropped the access mode. A named read-only volume like data:/var/lib/mysql:ro became data-<suffix>:/var/lib/mysql, so a read-only mount turned read-write, and the SELinux :z / :Z relabel flags were lost.

This PR preserves any segments after the container path and re-appends them, so data:/var/lib/mysql:ro becomes data-<suffix>:/var/lib/mysql:ro. Bind mounts and long-form (type: volume) entries are unchanged. A regression test is added covering :ro on a named volume and :z on a subdirectory volume.

Checklist

Before submitting this PR, please make sure that:

  • You created a dedicated branch based on the canary branch.
  • You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request
  • You have tested this PR in your local instance. Verified via the compose test suite (142 tests pass, including the new mode-preservation regression test) and tsc --noEmit on both @dokploy/server and apps/dokploy.

Issues related (if applicable)

closes #4818

Screenshots (if applicable)

Not applicable (backend compose transform). Behavior is covered by the added unit test.

The isolated-deployment and randomize transform split each volume mount
on ":" and kept only the name and path, dropping any access mode. A named
read-only volume like `data:/var/lib/mysql:ro` became
`data-<suffix>:/var/lib/mysql`, silently turning a read-only mount
read-write (and losing the SELinux :z and :Z relabel flags).

Preserve any segments after the path and re-append them so the mode
survives the suffixing. Add a regression test covering :ro on a named
volume and :z on a subdirectory volume.

Fixes Dokploy#4818
@tanaymishra tanaymishra requested a review from Siumauricio as a code owner July 13, 2026 18:43
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compose Randomize / Isolated Deployment drops named-volume access mode (:ro, :z, :Z), turning read-only mounts read-write

1 participant