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
feat: relative parent paths on bind mount src #4966
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4966 +/- ##
=======================================
Coverage 61.18% 61.19%
=======================================
Files 294 294
Lines 20538 20538
=======================================
+ Hits 12566 12568 +2
+ Misses 7077 7076 -1
+ Partials 895 894 -1 |
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.
Leaving a "request changes" as this may need discussion / consensus; the --mount
"advanced" syntax has various parts that were intentionally lower level (and not applying magic, but instead "as provided").
Maybe it's ok to make this change (as it still requires "opt-in" through ./
as prefix), but it's good to double check if we don't overlook situations where this could be problematic.
(If not, then happy to remove my "request for changes")
Oh, wait; guess I'm reading wrong; this is adding |
Yes! :) |
Gotcha! I'm slightly on the fence if this would be fixing a problem, or also potentially result in confusing / ambiguous situations; docker run -it --rm alpine
/ # ls .
bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
/ # ls ..
bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
/ # ls ../../../../
bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var FWIW; the current directory case on its own already had some consequences (i.e., the path you specify will be used on thee daemon side to mount, where the daemon could be "a remote machine"). Before that patch, we didn't decide to add local resolving of the path, as technically it would be "incorrect" (or at least add to the expectation that bind-mounts happen from the client side); we ultimately chose to implement it as mounting the "current" directory was a very common use-case, and "worked" on either Docker Desktop or a local daemon. |
I don't think this is fixing anything, more of a nice to have IMO. I'm sure there are situations where you'd like to specify a parent directory to bind the volume to while running from the current directory.
|
It seems based on the original discussion we allowed to have a relative path as long as it started with the
|
This is a follow-up PR of #3469
- What I did
The
source
value of-v/--volume/--mount
is validated, if not absolute and contains the.
prefix the value is converted to an absolute path. This prefix (.
) is always required forsource
since the-v/--volume/--mount
flags also support setting named volumes.- How I did it
- How to verify it
docker run --rm -v ../:/test busybox ls -l /test
docker run --rm --mount type=bind,source=../,target=/test busybox ls -l /test
- Description for the changelog
The run command accepts relative parent paths (
../
) on-v/--volume
and-m/--mount
.- A picture of a cute animal (not mandatory but encouraged)