GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement Subpath Support for Volumes in Docker-Py (#3243) by Khushiyant · Pull Request #3270 · docker/docker-py

Conversation

@Khushiyant

@Khushiyant Khushiyant commented Jun 13, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Closes #3243

This PR aims to add subpath support for volumes, allowing users to specify a subpath when creating a volume or a container. This feature is essential for scenarios where a container needs to access a specific directory within a volume.

  • Updated the Mount class in docker/types/mounts.py to include a subpath attribute.
  • Added tests/integration/api_container_test.py::VolumeBindTest::test_create_with_subpath_volume_mount to verify subpath working

Refer Docker Engine v26.0 and Docker API v1.45

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rayrapetyan reacted with eyes emoji
All reactions
  • 👀 1 reaction
@Khushiyant Khushiyant changed the title Implement Subpath Support for Volumes in Docker-Py Implement Subpath Support for Volumes in Docker-Py (#3243) Jun 13, 2024
@Khushiyant
Khushiyant force-pushed the volume-subpath branch from 32bb4c5 to 5edcbe4 Compare June 13, 2024 13:32
@rayrapetyan

rayrapetyan commented Sep 16, 2024

Copy link
Copy Markdown

Hello, can this PR be merged ASAP?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Khushiyant

Khushiyant commented Sep 16, 2024

Copy link
Copy Markdown
Contributor Author

@rayrapetyan Even, I'm also waiting for the review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Khushiyant
Khushiyant marked this pull request as ready for review September 16, 2024 05:13
@rayrapetyan

rayrapetyan commented Sep 16, 2024

Copy link
Copy Markdown

@thaJeztah @krissetto, could you provide a review please, this seems like a very simple and straightforward change. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rayrapetyan
rayrapetyan approved these changes Sep 16, 2024
View reviewed changes
@rayrapetyan

rayrapetyan commented Sep 16, 2024

Copy link
Copy Markdown

@Khushiyant, could you re-trigger the build as seems one of the integration tests has failed before.

Khushiyant reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Khushiyant
Khushiyant force-pushed the volume-subpath branch from 6b8bbb5 to b9fc1ea Compare September 17, 2024 09:53
@Khushiyant

Khushiyant commented Sep 17, 2024

Copy link
Copy Markdown
Contributor Author

@Khushiyant, could you re-trigger the build as seems one of the integration tests has failed before.

Yeah, I triggered the build and now, all tests have passed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

krissetto
krissetto reviewed Sep 17, 2024
View reviewed changes

@krissetto krissetto left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the contribution!
I gave this a quick look for now, we'll try to get it in soon

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread docker/api/volume.py Outdated
driver (str): Name of the driver used to create the volume
driver_opts (dict): Driver options as a key-value dictionary
labels (dict): Labels to set on the volume
subpath (str): Subpath within the volume to use as the volume's

@krissetto krissetto Sep 17, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd change this to

subpath (str): Path inside a volume to mount instead of the volume root.

To better match documentation we have elsewhere (eg https://github.com/docker/docs/blob/23f3fbd0639a24d0e2280fd0edb7f72b3f0cb1ca/content/reference/compose-file/services.md?plain=1#L1865)

@dvdksn WDYT?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dvdksn reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@dvdksn dvdksn Sep 17, 2024

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

SGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread docker/types/services.py Outdated
for the ``volume`` type.
driver_config (DriverConfig): Volume driver configuration. Only valid
for the ``volume`` type.
subpath (string): The path within the volume where the container's

@krissetto krissetto Sep 17, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd keep this the same as the suggestion above ☝️

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/integration/api_container_test.py Outdated
mount = docker.types.Mount(
type="volume", source=helpers.random_name(),
target=self.mount_dest, read_only=True,
subpath='subdir'

@krissetto krissetto Sep 17, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

From a quick glance, it doesn't seem that the subpath is being checked in this test

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Khushiyant Khushiyant Sep 17, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Made changes accordingly

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread docker/types/services.py Outdated
if driver_config:
volume_opts['DriverConfig'] = driver_config
if subpath:
volume_opts['SubPath'] = subpath

@krissetto krissetto Sep 17, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think this should be written as Subpath here, right @vvoland?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Khushiyant Khushiyant Sep 17, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yeah, it is Subpath instead of SubPath: moby#45687. I'll change this quick

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Khushiyant
Khushiyant commented Sep 17, 2024
View reviewed changes
Comment thread docker/types/services.py
if driver_config:
volume_opts['DriverConfig'] = driver_config
if subpath:
volume_opts['Subpath'] = subpath

@Khushiyant Khushiyant Sep 17, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Change the SubPath to Subpath

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
krissetto
krissetto reviewed Sep 17, 2024
View reviewed changes
Comment thread tests/integration/api_container_test.py Outdated
mount_data = filtered[0]
assert mount['Source'] == mount_data['Name']
assert mount_data['RW'] is False
assert mount["VolumeOptions"]["Subpath"] == "subdir"

@krissetto krissetto Sep 17, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is testing that the input mount options, as defined above on line 628, are the same.

The test needs to check that the path mounted inside the container corresponds to the subdir as defined in the mount options. The volume mounted must therefore contain the subdir, or else there should be an error.

Maybe you could change to check mount_data instead, if it contains the necessary info? I don't have much time now but I'd have to check how these volume tests are defined in a bit more detail later

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Khushiyant Khushiyant Sep 17, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Oh, sure.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Khushiyant
Khushiyant force-pushed the volume-subpath branch from 39ed407 to 4213fed Compare March 7, 2025 18:00
@Khushiyant
Khushiyant marked this pull request as draft March 18, 2025 15:23
@Khushiyant
Khushiyant force-pushed the volume-subpath branch 3 times, most recently from 6f5b179 to 64c2101 Compare March 18, 2025 17:26
@Khushiyant

Khushiyant commented Mar 18, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I have cleaned up the commit history while removing unnecessary changes and also corrected tests

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Khushiyant
Khushiyant marked this pull request as ready for review March 18, 2025 17:32
@Khushiyant
Khushiyant requested a review from krissetto March 18, 2025 17:33
@Khushiyant
Khushiyant force-pushed the volume-subpath branch 3 times, most recently from df5eaa3 to f86cf65 Compare March 18, 2025 17:45
@Khushiyant
feat(docker/api/container): add support for subpath in volume_opts
820769e
TESTED: Yes, added unit tests to verify subpath functionality
Signed-off-by: Khushiyant <[email protected]>
@Khushiyant
Khushiyant force-pushed the volume-subpath branch from f86cf65 to 820769e Compare March 18, 2025 17:46
@Khushiyant
Khushiyant requested a review from rayrapetyan March 18, 2025 17:58
vvoland
vvoland approved these changes Jun 11, 2025
View reviewed changes
@vvoland
vvoland merged commit 6e6a273 into docker:main Jun 11, 2025
@robstolarz robstolarz mentioned this pull request Oct 2, 2025
New release #3361
Closed
mergify Bot added a commit to ArcadeData/arcadedb that referenced this pull request Jul 12, 2026
@mergify
chore(deps): update docker requirement from >=7.1.0 to >=7.2.0 in /e2…
698baf0
…e-python [skip ci]

Updates the requirements on [docker](https://github.com/docker/docker-py) to permit the latest version.
Release notes

*Sourced from [docker's releases](https://github.com/docker/docker-py/releases).*

> 7.2.0
> -----
>
> Upgrade Notes
> -------------
>
> * `docker.from_env()` now honors the active Docker CLI context when `DOCKER_HOST` is not set.
>   + This means the client may connect to the daemon selected by `DOCKER_CONTEXT` or the current context in `~/.docker/config.json`, matching Docker CLI behavior more closely.
>   + If your application relied on the previous default connection behavior, set `DOCKER_HOST` explicitly, set `DOCKER_CONTEXT=default`, or pass `use_context=False` to `DockerClient.from_env()`.
> * Added `docker.from_context()` / `DockerClient.from_context()` for explicitly creating a client from a Docker CLI context.
>
> Features
> --------
>
> * Added support for Docker contexts when creating the default client
> * Added subpath support for volumes
>
> Bugfixes
> --------
>
> * Fixed `exec_run` documentation for the `stream` parameter
> * Fixed image loading to avoid depending on the deprecated `JSONMessage.error` field
> * Preserved the rotated unlock key in swarm integration tests
> * Fixed SSL certificate generation in tests
> * Fixed IPv6 integration tests by explicitly enabling IPv6 where required
>
> Miscellaneous
> -------------
>
> * Updated tests for newer Docker Engine behavior
> * CI and build updates
>
> What's Changed
> --------------
>
> * tests/exec: expect 127 exit code for missing executable by [`@​laurazard`](https://github.com/laurazard) in [docker/docker-py#3290](https://redirect.github.com/docker/docker-py/pull/3290)
> * fixing doc for stream param in exec\_run by [`@​yasonk`](https://github.com/yasonk) in [docker/docker-py#3292](https://redirect.github.com/docker/docker-py/pull/3292)
> * Bump default API version to 1.45 (Moby 26.0/26.1) by [`@​thaJeztah`](https://github.com/thaJeztah) in [docker/docker-py#3261](https://redirect.github.com/docker/docker-py/pull/3261)
> * Set a dummy-version if none set, and remove unused APT\_MIRROR build-arg by [`@​thaJeztah`](https://github.com/thaJeztah) in [docker/docker-py#3267](https://redirect.github.com/docker/docker-py/pull/3267)
> * test\_service\_logs: stop testing experimental versions by [`@​thaJeztah`](https://github.com/thaJeztah) in [docker/docker-py#2442](https://redirect.github.com/docker/docker-py/pull/2442)
> * Makefile: fix circular reference for integration-dind by [`@​thaJeztah`](https://github.com/thaJeztah) in [docker/docker-py#3297](https://redirect.github.com/docker/docker-py/pull/3297)
> * image load: don't depend on deprecated JSONMessage.error field by [`@​thaJeztah`](https://github.com/thaJeztah) in [docker/docker-py#3307](https://redirect.github.com/docker/docker-py/pull/3307)
> * integration: test\_create\_volume\_invalid\_driver allow either 400 or 404 by [`@​thaJeztah`](https://github.com/thaJeztah) in [docker/docker-py#3296](https://redirect.github.com/docker/docker-py/pull/3296)
> * integration: adjust tests for omitted "OnBuild" by [`@​thaJeztah`](https://github.com/thaJeztah) in [docker/docker-py#3336](https://redirect.github.com/docker/docker-py/pull/3336)
> * Implement Subpath Support for Volumes in Docker-Py ([#3243](https://redirect.github.com/docker/docker-py/issues/3243)) by [`@​Khushiyant`](https://github.com/Khushiyant) in [docker/docker-py#3270](https://redirect.github.com/docker/docker-py/pull/3270)
> * tests: fix ssl generation by [`@​thaJeztah`](https://github.com/thaJeztah) in [docker/docker-py#3365](https://redirect.github.com/docker/docker-py/pull/3365)
> * test/integration: don't check for deprecated Networks field by [`@​thaJeztah`](https://github.com/thaJeztah) in [docker/docker-py#3362](https://redirect.github.com/docker/docker-py/pull/3362)
> * test: Skip from\_env\_unix tests if DOCKER\_HOST is network socket by [`@​ricardobranco777`](https://github.com/ricardobranco777) in [docker/docker-py#3366](https://redirect.github.com/docker/docker-py/pull/3366)
> * test\_connect\_with\_ipv6\_address: enable IPv6 by [`@​robmry`](https://github.com/robmry) in [docker/docker-py#3372](https://redirect.github.com/docker/docker-py/pull/3372)
> * test\_create\_with\_ipv6\_address: enable IPv6 by [`@​robmry`](https://github.com/robmry) in [docker/docker-py#3373](https://redirect.github.com/docker/docker-py/pull/3373)
> * tests: Migrate off gpg2 and regenerate key ed25519 by [`@​vvoland`](https://github.com/vvoland) in [docker/docker-py#3399](https://redirect.github.com/docker/docker-py/pull/3399)
> * gha: Pin to digests by [`@​vvoland`](https://github.com/vvoland) in [docker/docker-py#3408](https://redirect.github.com/docker/docker-py/pull/3408)
> * Fix integration tests on non-amd64 hosts and add ARM64 CI by [`@​vvoland`](https://github.com/vvoland) in [docker/docker-py#3407](https://redirect.github.com/docker/docker-py/pull/3407)
> * integration/swarm: Preserve rotated unlock key by [`@​vvoland`](https://github.com/vvoland) in [docker/docker-py#3410](https://redirect.github.com/docker/docker-py/pull/3410)
> * [DKP-2535] Honour context if present for default client, add contexts support by [`@​ebriney`](https://github.com/ebriney) in [docker/docker-py#3401](https://redirect.github.com/docker/docker-py/pull/3401)
> * docs: 7.2.0 changelog by [`@​vvoland`](https://github.com/vvoland) in [docker/docker-py#3415](https://redirect.github.com/docker/docker-py/pull/3415)
>
> New Contributors
> ----------------
>
> * [`@​laurazard`](https://github.com/laurazard) made their first contribution in [docker/docker-py#3290](https://redirect.github.com/docker/docker-py/pull/3290)
> * [`@​yasonk`](https://github.com/yasonk) made their first contribution in [docker/docker-py#3292](https://redirect.github.com/docker/docker-py/pull/3292)
> * [`@​ricardobranco777`](https://github.com/ricardobranco777) made their first contribution in [docker/docker-py#3366](https://redirect.github.com/docker/docker-py/pull/3366)

... (truncated)


Commits

* [`5ad5327`](docker/docker-py@5ad5327) Merge pull request [#3415](https://redirect.github.com/docker/docker-py/issues/3415) from vvoland/update-changelog
* [`d242230`](docker/docker-py@d242230) docs: 7.2.0 changelog
* [`ba01cc7`](docker/docker-py@ba01cc7) Merge pull request [#3401](https://redirect.github.com/docker/docker-py/issues/3401) from ebriney/client-from-context
* [`ae5dfe9`](docker/docker-py@ae5dfe9) Merge pull request [#3410](https://redirect.github.com/docker/docker-py/issues/3410) from vvoland/fix-flaky
* [`aa99999`](docker/docker-py@aa99999) integration/swarm: Preserve rotated unlock key
* [`059d371`](docker/docker-py@059d371) Merge pull request [#3407](https://redirect.github.com/docker/docker-py/issues/3407) from vvoland/fix-arm64
* [`9b4b9b8`](docker/docker-py@9b4b9b8) gha: Add arm64 integration CI
* [`9e9f8ff`](docker/docker-py@9e9f8ff) Skip tests incompatible with host architecture
* [`e0542d9`](docker/docker-py@e0542d9) Merge pull request [#3408](https://redirect.github.com/docker/docker-py/issues/3408) from vvoland/gha-pin
* [`578a11d`](docker/docker-py@578a11d) gha: Pin to digests
* Additional commits viewable in [compare view](docker/docker-py@7.1.0...7.2.0)
  
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vvoland vvoland vvoland approved these changes
@krissetto krissetto Awaiting requested review from krissetto
@rayrapetyan rayrapetyan Awaiting requested review from rayrapetyan
+1 more reviewer
@dvdksn dvdksn dvdksn left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Mount of volume-subpath which is available in Docker version 26.0.0, build 2ae903e using Python SDK for docker

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@Khushiyant @rayrapetyan @vvoland @dvdksn @krissetto
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.