Skip to content

Conversation

@fccagou
Copy link
Contributor

@fccagou fccagou commented Dec 7, 2025

To allow subpath mount as describes in Compose Specs, in complement of #1336

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 feat-process-subpath-in-volume-type branch 3 times, most recently from e4f7ada to 740aa00 Compare December 7, 2025 17:36
Copy link
Collaborator

@p12tic p12tic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but please check unit test failures.

@fccagou fccagou force-pushed the feat-process-subpath-in-volume-type branch 7 times, most recently from 20d75c3 to e97a969 Compare December 9, 2025 21:04
To allow subpath mount as describes in [Compose Specs](https://github.com/compose-spec/compose-spec/blob/main/05-services.md),

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
Copy link
Contributor Author

fccagou commented Dec 9, 2025

The test added is finally removed because get_mount_args calls assert_volume which fails running podman inspect volume xxxx. In the testcase contexte, this returns unexpected NoneType then break calling .decode("utf-8") podman_compose.py:430

@p12tic
Copy link
Collaborator

p12tic commented Dec 10, 2025

Tests can still be added for mount_desc_to_mount_args. As for get_mount_args, would it be possible to patch assert_volume to do nothing for test?

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.

2 participants