-
Notifications
You must be signed in to change notification settings - Fork 5.5k
mount API is not strictly equivalent to bind #12722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@ndeloof I think this was the comment where the original idea of “allow a named volume with a custom host path” (so, largely a “bind-mount”) comes from; moby/moby#19990 (comment) Note that the comment was really a "hack"; it depends on knowing the right options for the mount syscall, and it's tricking the docker engine into thinking it deals with a volume, not a bind-mount (to do the "copy files to the target destination"). One thing to be aware of is that in that (technically) “o=bind” could have multiple options; also (as mentioned) that it DOES act as a volume, because the docker engine is not aware of the mount syscall options; for example; docker volume create --opt type=none --opt device=/root/mount-target --opt o=bind bindvolume This is expected: docker is not aware of any host-path dependency that the mount syscall options require; docker run --rm -v bindvolume:/usr/share/nginx/ nginx:alpine sh -c 'echo hello > /usr/share/nginx/html/foo.txt'
# docker: Error response from daemon: failed to mount local volume: mount /root/mount-target:/var/lib/docker/volumes/bindvolume/_data, flags: 0x1000: no such file or directory. Creating the path first makes it work, but also be aware that the Docker Engine considers it a volume, so (unlike a bind-mount) will copy files to the given location if the target path on the host is empty; mkdir -p /root/mount-target
docker run --rm -v bindvolume:/usr/share/nginx/ nginx:alpine sh -c 'echo hello > /usr/share/nginx/html/foo.txt'
tree /root/mount-target
/root/mount-target
└── html
├── 50x.html
├── foo.txt
└── index.html
1 directory, 3 files |
Hi, just stumbled over this by accident. We are using volumes like @thaJeztah showed to have docker volumes with the copy behavior on a custom host path. Another upside is that deleting the volume does not delete the underyling data :) I don't fully understand what this MR changes, but it would be great if this "hack" would continue to work (or at least offers a different way to achieve the same). |
In general, named volumes were designed for that specifically; if a volume has a name, docker will avoid deleting it (unless you ask it to), e.g. |
Yes, but adding a label to a volume is not something docker compose can do without destroying the volume which is unfortunate.
Yes, but using a VM can already be considered a hack in itself :D |
a66b549
to
89cb84a
Compare
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
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.
Sounds good to me, we just need to double check the TypeNamedPipe
case
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [docker/compose](https://github.com/docker/compose) | minor | `v2.34.0` -> `v2.36.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>docker/compose (docker/compose)</summary> ### [`v2.36.0`](https://github.com/docker/compose/releases/tag/v2.36.0) [Compare Source](docker/compose@v2.35.1...v2.36.0) #### What's Changed 🎉 You can now use external binaries as service provider to extend Compose behaviour. For more information about creating your own plugin check [the documentation](https://github.com/docker/compose/blob/main/docs/extension.md) ##### ✨ Improvements - Introduce `networks.interface_name` by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12771 - Add support for `COMPOSE_PROGRESS` env variable by [@​AnvarU](https://github.com/AnvarU) in docker/compose#12769 - Document extensibility using service.provider and open provider to external binaries by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12777 - Introduce build `--check` by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12765 ##### 🐛 Fixes - Build: write `--print` output to stdout by [@​emersion](https://github.com/emersion) in docker/compose#12756 - Fix: concurrent map writes when pulling by [@​skanehira](https://github.com/skanehira) in docker/compose#12752 - Fix support for remote absolute path by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12786 - Fix collect image digests for service images built by bake by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12784 - Enable services implicitly declared by a service:xx build dependency by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12785 - Fix config `--variables` not honoring the `--format` flag by [@​alessio-perugini](https://github.com/alessio-perugini) in docker/compose#12809 ##### 🔧 Internal - Remove support of Synchronize File Shares integration with Docker Desktop by [@​glours](https://github.com/glours) in docker/compose#12763 - Display proper event message for provider services on up and down by [@​glours](https://github.com/glours) in docker/compose#12788 - E2e test for start_interval by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12795 - Document behavior on missing extension by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12802 ##### ⚙️ Dependencies - Build(deps): bump github.com/docker/cli from `28.1.0+incompatible` to `28.1.1+incompatible` by [@​dependabot](https://github.com/dependabot) in docker/compose#12761 - Build(deps): bump github.com/docker/docker from `28.1.0+incompatible` to `28.1.1+incompatible` by [@​dependabot](https://github.com/dependabot) in docker/compose#12759 - Build(deps): bump google.golang.org/grpc from `1.71.1` to `1.72.0` by [@​dependabot](https://github.com/dependabot) in docker/compose#12760 - Build(deps): bump github.com/containerd/containerd/v2 from `2.0.4` to `2.0.5` by [@​dependabot](https://github.com/dependabot) in docker/compose#12758 - Bump compose-go to `v2.6.1` by [@​glours](https://github.com/glours) in docker/compose#12766 - Bump compose-go to `v2.6.2` by [@​glours](https://github.com/glours) in docker/compose#12810 - Build(deps): bump github.com/moby/buildkit from `0.21.0` to `0.21.1` by [@​dependabot](https://github.com/dependabot) in docker/compose#12796 - Build(deps): bump golang.org/x/sync from `0.13.0` to `0.14.0` by [@​dependabot](https://github.com/dependabot) in docker/compose#12805 - Build(deps): bump golang.org/x/sys from `0.32.0` to `0.33.0` by [@​dependabot](https://github.com/dependabot) in docker/compose#12804 - Build(deps): bump go.uber.org/mock from `0.5.1` to `0.5.2` by [@​dependabot](https://github.com/dependabot) in docker/compose#12792 #### New Contributors - [@​skanehira](https://github.com/skanehira) made their first contribution in docker/compose#12752 - [@​AnvarU](https://github.com/AnvarU) made their first contribution in docker/compose#12769 - [@​alessio-perugini](https://github.com/alessio-perugini) made their first contribution in docker/compose#12809 **Full Changelog**: docker/compose@v2.35.1...v2.36.0 ### [`v2.35.1`](https://github.com/docker/compose/releases/tag/v2.35.1) [Compare Source](docker/compose@v2.35.0...v2.35.1) #### What's Changed ##### 🐛 Fixes - Use bind API for bind mounts by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12733 - Prefer bind API by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12734 ##### 🔧 Internal - CI(bin-image): free disk space by [@​crazy-max](https://github.com/crazy-max) in docker/compose#12732 - Fix zizmor security alerts on GHA workflows by [@​glours](https://github.com/glours) in docker/compose#12737 - Chore: make function comment match function name by [@​dufucun](https://github.com/dufucun) in docker/compose#12748 - Migrate to use github.com/moby/go-archive by [@​thaJeztah](https://github.com/thaJeztah) in docker/compose#12716 ##### ⚙️ Dependencies - Build(deps): bump github.com/moby/buildkit from `0.20.1` to `0.20.2` by [@​dependabot](https://github.com/dependabot) in docker/compose#12667 - Build(deps): bump google.golang.org/grpc from `1.71.0` to `1.71.1` by [@​dependabot](https://github.com/dependabot) in docker/compose#12691 - Build(deps): bump go.uber.org/mock from `0.5.0` to `0.5.1` by [@​dependabot](https://github.com/dependabot) in docker/compose#12720 - Build(deps): bump golang.org/x/crypto from `0.32.0` to `0.35.0` by [@​dependabot](https://github.com/dependabot) in docker/compose#12745 - Bump buildkit `v0.21.0`, buildx `v0.23.0` by [@​thaJeztah](https://github.com/thaJeztah) in docker/compose#12754 - Downgrade go-difflib and go-spew to tagged releases by [@​thaJeztah](https://github.com/thaJeztah) in docker/compose#12755 - Bump github.com/docker/docker, github.com/docker/cli `v28.1.0` by [@​thaJeztah](https://github.com/thaJeztah) in docker/compose#12738 #### New Contributors - [@​dufucun](https://github.com/dufucun) made their first contribution in docker/compose#12748 **Full Changelog**: docker/compose@v2.35.0...v2.35.1 ### [`v2.35.0`](https://github.com/docker/compose/releases/tag/v2.35.0) [Compare Source](docker/compose@v2.34.0...v2.35.0) #### What's Changed 🎉 1st implementation of external services feature to support Docker Model Runner in Compose by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12692 ##### ✨ Improvements - Set `$PWD` (may not be supported on Windows) by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12643 - Introduce config `--no-env-resolution` by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12665 - Introduce `build --print` to dump equivalent bakefile by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12675 - Feat(run): Add `--quiet` and `--quiet-build` options for the `run` command by [@​idsulik](https://github.com/idsulik) in docker/compose#12685 - Introduce `volume.type=image` by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12725 ##### 🐛 Fixes - Fix support for secret set by env inside included file by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12635 - Fix edge-case bug checking path prefix in watch for bind mount volumes by [@​matiboux](https://github.com/matiboux) in docker/compose#12640 - Run only loads required service env_file and ignores others by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12645 - Fixed support for `depends_on.restart` in `up` and `restart` commands by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12649 - Bake parses "${}" in DockerfileInline as a variable by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12664 - Fix(secrets): Reverted secrets file mode 440 -> 444 by [@​idsulik](https://github.com/idsulik) in docker/compose#12666 - Fix scale completion by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12672 - Fix: replace `docker-compose.yml` with `compose.yaml` by [@​k-kbk](https://github.com/k-kbk) in docker/compose#12680 - Include implicit build dependencies in build command by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12683 - Capture git fetch output when debug output is enabled by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12719 - Mount API is not strictly equivalent to bind by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12722 ##### 🔧 Internal - Test commandName subcommand order by [@​maxproske](https://github.com/maxproske) in docker/compose#12535 - Set watch option --prune=true as default by [@​remcokranenburg](https://github.com/remcokranenburg) in docker/compose#12650 - Plugin Docker Desktop Model Runner check by [@​glours](https://github.com/glours) in docker/compose#12718 - pkg/compose: implement Export using atomicwriter by [@​thaJeztah](https://github.com/thaJeztah) in docker/compose#12715 - Style: refactor Desktop client for readability and maintainability by [@​Saracomethstein](https://github.com/Saracomethstein) in docker/compose#12723 ##### ⚙️ Dependencies - Build(deps): bump github.com/docker/buildx from `0.21.2` to `0.21.3` by [@​dependabot](https://github.com/dependabot) in docker/compose#12646 - Build(deps): bump github.com/containerd/containerd/v2 from `2.0.3` to `2.0.4` by [@​dependabot](https://github.com/dependabot) in docker/compose#12647 - Bump docker & cli `v28.0.4` and buildx `v0.22.0` by [@​ndeloof](https://github.com/ndeloof) in docker/compose#12674 - Bump golangci-lint to version `v2.0.2` by [@​glours](https://github.com/glours) in docker/compose#12689 - Bump golang to `1.23.8` by [@​glours](https://github.com/glours) in docker/compose#12698 - Update secret detector to fix vulnerability https://github.com/golang… by [@​sigi-glovebox](https://github.com/sigi-glovebox) in docker/compose#12707 - Build(deps): bump golang.org/x/sys from `0.31.0` to `0.32.0` by [@​dependabot](https://github.com/dependabot) in docker/compose#12713 - Build(deps): bump golang.org/x/sync from `0.12.0` to `0.13.0` by [@​dependabot](https://github.com/dependabot) in docker/compose#12712 - Build(deps): bump github.com/compose-spec/compose-go/v2 from `2.5.1-0.20250409070949-8e1a035095ca` to `2.6.0` by [@​dependabot](https://github.com/dependabot) in docker/compose#12729 #### New Contributors - [@​matiboux](https://github.com/matiboux) made their first contribution in docker/compose#12640 - [@​k-kbk](https://github.com/k-kbk) made their first contribution in docker/compose#12680 - [@​sigi-glovebox](https://github.com/sigi-glovebox) made their first contribution in docker/compose#12707 - [@​Saracomethstein](https://github.com/Saracomethstein) made their first contribution in docker/compose#12723 **Full Changelog**: docker/compose@v2.34.0...v2.35.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yNTkuMCIsInVwZGF0ZWRJblZlciI6IjM5LjI2NC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
What I did
A volume mount with an actual bind (driver option
o: bind
) must be configured usingbind
API otherwise we get some weird behaviorRelated issue
https://docker.atlassian.net/browse/CSESC-577
(not mandatory) A picture of a cute animal, if possible in relation to what you did