Skip to content

Conversation

@fccagou
Copy link
Contributor

@fccagou fccagou commented Oct 19, 2025

Add subpath support to volumes in --mount option

To allow subpath mount as describes in Compose Specs,
refer_volume_over_mount is changed from True to False

Compose entries exemple:

    - type: volume
      source: webservices
      target: /srv/www/vhosts/server1
      read_only: true
      volume:
        subpath: server1
    - type: volume
      source: webservices
      target: /srv/www/vhosts/server2
      read_only: true
      volume:
        subpath: server2
    - type: volume
      source: webservices
      target: /srv/www/vhosts/server2/uploads
      read_only: false
      volume:
        subpath: server2/uploads

Runs podman with options

    --mount type=volume,source=webservices,target=/srv/www/vhosts/server1,ro
    --mount type=volume,source=webservices,target=/srv/www/vhosts/server2,ro,subpath=server2
    --mount type=volume,source=webservices,target=/srv/www/vhosts/server2/uploads,subpath=server2/uploads

Contributor Checklist:

If this PR adds a new feature that improves compatibility with docker-compose, please add a link
to the exact part of compose spec that the PR touches.

For any user-visible change please add a release note to newsfragments directory, e.g.
newsfragments/my_feature.feature. See newsfragments/README.md for more details.

All changes require additional unit tests.

@fccagou fccagou force-pushed the fix-subpath-silently-ignored branch 6 times, most recently from da088d3 to b4728f4 Compare October 19, 2025 09:49
To allow subpath mount as describes in [Compose Specs](https://github.com/compose-spec/compose-spec/blob/main/05-services.md),
`refer_volume_over_mount` is changed from _True_ to **False**

Compose entries exemple:

    - type: volume
      source: webservices
      target: /srv/www/vhosts/server1
      read_only: true
      volume:
        subpath: server1
    - type: volume
      source: webservices
      target: /srv/www/vhosts/server2
      read_only: true
      volume:
        subpath: server2
    - type: volume
      source: webservices
      target: /srv/www/vhosts/server2/uploads
      read_only: false
      volume:
        subpath: server2/uploads

Runs podman with options

    --mount type=volume,source=webservices,target=/srv/www/vhosts/server1,ro
    --mount type=volume,source=webservices,target=/srv/www/vhosts/server2,ro,subpath=server2
    --mount type=volume,source=webservices,target=/srv/www/vhosts/server2/uploads,subpath=server2/uploads

Signed-off-by: fccagou <me@fccagou.fr>
@fccagou fccagou force-pushed the fix-subpath-silently-ignored branch from b4728f4 to 62f1f36 Compare October 19, 2025 10:19
@fccagou fccagou changed the title fix(volumes): manage subpath into volume Add subpath support to volumes in --mount option Oct 20, 2025
@fccagou fccagou force-pushed the fix-subpath-silently-ignored branch from 53ac9a7 to 3230e3c Compare October 20, 2025 19:10
Signed-off-by: fccagou <me@fccagou.fr>
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