Skip to content

Conversation

@vvoland
Copy link
Collaborator

@vvoland vvoland commented Feb 11, 2026

Add support for the bind-create-host-path option in bind mounts, which instructs the daemon to create the mountpoint directory inside the container if it doesn't exist.

This allows to replace the legacy -v /src/dir:/dst with the --mount.

Usage:
--mount type=bind,src=/host/path,dst=/container/path,bind-create-host-path
--mount type=bind,src=/host/path,dst=/container/path,bind-create-host-path=true

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

Add `bind-create-host-path` option to `--mount` flag for bind mounts.

- A picture of a cute animal (not mandatory but encouraged)

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@thaJeztah
Copy link
Member

Oh! I now recall I saw a PR from @ndeloof which I think is doing the same, but I had to think about the naming of the option (he picked bind-create-host-path);

host path is probably more correct though, because it's creating the path on the host (if missing); destination path (inside the container) should always be created?

@vvoland
Copy link
Collaborator Author

vvoland commented Feb 11, 2026

I think it should be bind-create-mountpoint to match the API param. Perhaps we should rename it on the API level too?

@thaJeztah
Copy link
Member

Yeah, we probably didn't think it through properly when we named the API field 😞. For the CLI, UX doesn't have to strictly match the API naming of course.

But yeah; ideally we'd rename the API field, but that may need some juggling to deprecate the old (so perhaps we'd need "both" for some time).

@thaJeztah
Copy link
Member

Oh! Regardless of that; Nicolas's PR also has some documentation changes; if we continue on this PR, we should include those here (you can add him as co-authored-by).

@vvoland vvoland requested a review from a team as a code owner February 11, 2026 14:11
@vvoland vvoland added this to the 29.3.0 milestone Feb 11, 2026
@thaJeztah
Copy link
Member

Thanks for updating; I was also brainstorming a bit on alternative, descriptive names; one option could also be bind-create-src (as src is the option used to specify the host path).

By default, bind mounts require the source path to exist on the host. This is a significant difference
from the <tt>-v</tt> flag, which creates the source path if it doesn't exist.<br />
<br />
Set <tt>bind-create-host-path</tt> to create the source path on the host if it doesn't exist.<br />
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we should be explicit, and mention "on the daemon host", because that's where it happens.

@dvdksn perhaps you have more / other suggestions.

Add support for the `bind-create-mountpoint` option in bind mounts,
which instructs the daemon to create the mountpoint directory inside the
container if it doesn't exist.

This allows to replace the legacy `-v /src/dir:/dst` with the `--mount`.

Usage:
--mount type=bind,src=/host/path,dst=/container/path,bind-create-mountpoint
--mount type=bind,src=/host/path,dst=/container/path,bind-create-mountpoint=true

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the bind-create branch 2 times, most recently from d7d9df4 to bdd1a7a Compare February 12, 2026 15:45
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland changed the title container/opts: Add bind-create-mountpoint mount option container/opts: Add bind-create-host-path mount option Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants