cli: add --mount to docker run#26825
Conversation
6f4b095 to
8504601
Compare
dec2bc2 to
563986b
Compare
|
failure in windowsRS1 seems unrelated |
There was a problem hiding this comment.
Note: this cmd should succeed in the future when it migrated -v to the new mount api
There was a problem hiding this comment.
This error message is a little confusing. Do you mean volumes and mounts?
There was a problem hiding this comment.
The error was defined in https://github.com/docker/docker/pull/22373/files#diff-2660508eef7a8eeadb6d27b8bbf6d718R78 rather than in this PR.
IMO the error message is correct because -v /foo:/foo1 actually sets HostConfig.Binds rather than Config.Volumes.
But I agree we should improve the message.
CC @cpuguy83
There was a problem hiding this comment.
Yeah, it's a little funky now that this is on the CLI.... I'm not sure what to change it to. Maybe something like Mounts must be used exclusively from other formats (very much not this, but something like it 😄 ).
cc @thaJeztah
There was a problem hiding this comment.
removed the assertion itself in the last PR
|
My understanding is that parsing issues make migrating --volume difficult On 23 Sep 2016 8:57 a.m., "Akihiro Suda" [email protected] wrote:
|
stevvooe
left a comment
There was a problem hiding this comment.
Great to see this.
I noticed that some odd behavior has leaked in. Let's be mindful that we're not making design changes without considering.
The important one is that source isn't required for the volume type. This is equivalent to -v /foo, where an "anonymous" volume will be created at /foo.
docs/reference/commandline/run.md
Outdated
There was a problem hiding this comment.
Let's use volumes as the primary example of mounts. Binds should be a special case.
This example is salient, as well, so using this with a volume example will demonstrate the difference in behavior of volumes and bind.
There was a problem hiding this comment.
Please add a volume oriented test.
opts/mount_test.go
Outdated
There was a problem hiding this comment.
Please test at least one volume default.
opts/mount_test.go
Outdated
There was a problem hiding this comment.
Do we have readonly=true?
opts/mount_test.go
Outdated
There was a problem hiding this comment.
Source is not required for volumes.
There was a problem hiding this comment.
In current implementation, actually source is not required unless any volume-* is appended.
i.e. type=volume,target=/foo works but type=volume,target=/foo,volume-nocopy not.
@cpuguy83 Is there reason to require the source here?
There was a problem hiding this comment.
Originally only added source as required for when volume driver configs are set. We can probably relax this.
There was a problem hiding this comment.
source is not required for volumes. Let's fix that.
runconfig/opts/parse.go
Outdated
There was a problem hiding this comment.
What? This makes no sense. Binds is already supported via mounts.
There was a problem hiding this comment.
I meant we should not set HostConfig.Binds 💦 , I'll update the comment for clarity
There was a problem hiding this comment.
removed the comment in the last commit
opts/mount_test.go
Outdated
There was a problem hiding this comment.
Can we not further propagate this? This is really in danger of becoming some sort of protocol. Please remove the string method and let's use equality for testing.
There was a problem hiding this comment.
OK, but the code is from cli/command/service/opts_test.go, and I didn't touch substantial part in this PR.
For ease of tracking changes, I'd like to open another PR
There was a problem hiding this comment.
Yeah, not sure why we'd not use strong types here.
There was a problem hiding this comment.
The test named TestMountOptString seems made solely for testing the String() method itself.
So I think it is ok to keep the current code.
There was a problem hiding this comment.
@AkihiroSuda Leaving this String() risks this becoming a de-facto standard in the future.
There was a problem hiding this comment.
Tried to remove the String() method but it didn't compile
# github.com/docker/docker/runconfig/opts
runconfig/opts/parse.go:210: cannot use &copts.mounts (type *opts.MountOpt) as type pflag.Value in argument to flags.Var:
*opts.MountOpt does not implement pflag.Value (missing String method)There was a problem hiding this comment.
So, this was somewhat why I distrust String() here: it has leaked into the flags implementation. I think we can leave it in place for this PR.
Thank you for the information, could you show me concrete examples that cannot be easily migrated to the new interface? |
|
@AkihiroSuda from memory it was related to the different parsing rules for Windows with volumes, and the client does not know if it is talking to a Windows daemon or not. Will try to find the discussion. |
|
I have a branch I was playing around with that basically allows checking windows path semantics and unix path semantics. |
|
Not to mention the fact that the parse result is apportioned between the |
|
Thank you for comments. @cpuguy83 's approach seems work for both If we really cannot combine |
|
Hmm, maybe it is best to allow both, will think about this. On 27 Sep 2016 10:08 a.m., "Akihiro Suda" [email protected] wrote:
|
563986b to
439648e
Compare
|
updated PR, now it allows both the old interface and the new one. |
439648e to
309cb8c
Compare
|
Needs a rebase. @stevvooe please look at your review and see if it is all resolved. |
|
LGTM I'm still concerned about how this will interact with |
|
@AkihiroSuda Thanks for another great PR! This is a tough one... @cpuguy83 Are we ready for this? |
|
LGTM |
|
needs a rebase as well I moved to docs review, and will review shortly |
|
rebased and updated doc #26825 (comment) |
|
failure in windowsRS1 seems unrelated |
|
@AkihiroSuda needs a rebase and probably a docs update for |
thaJeztah
left a comment
There was a problem hiding this comment.
Left some suggestions, but looking good already
docs/reference/commandline/run.md
Outdated
There was a problem hiding this comment.
can you add an anchor to the link? service_create.md#add-bind-mounts-or-volumes
There was a problem hiding this comment.
I'd like to avoid using "new" in documentation, as it's no longer "new" in the next release. Something like;
### Add bin-mounts or volumes using the --mounts flag
The `--mounts` flag allows you to mount volumes, host-directories and `tmpfs`
mounts in a container.
The `--mount` flag supports most options that are supported by the `-v` or
`--volume` flag, but uses a different syntax. For in-depth information on the
`--mount` flag, and a comparisson between `--volume` and `--mount`, refer to
the [service create command
reference](service_create.md#add-bind-mounts-or-volumes).But I'm not very creative here, perhaps @mstanleyjones has a better suggestion 😄
There was a problem hiding this comment.
thank you for suggestion. updated PR
PTAL @mstanleyjones
|
@vdemeester This PR doesn't contain the code for tmpfs, but will be in another PR soon. |
contrib/completion/fish/docker.fish
Outdated
There was a problem hiding this comment.
"Attach a mount" seems vague / inaccurate. Maybe "Attach a filesystem mount" or "Mount a filesystem" or something like that?
There was a problem hiding this comment.
done ("Attach a filesystem mount")
contrib/completion/fish/docker.fish
Outdated
There was a problem hiding this comment.
If you reword above, reword here too.
contrib/completion/zsh/_docker
Outdated
There was a problem hiding this comment.
And here. (is there any way to avoid all this duplication?)
There was a problem hiding this comment.
done, it would be great if completions are automatically generated from the code..
docs/reference/commandline/run.md
Outdated
Signed-off-by: Akihiro Suda <[email protected]>
|
updated and rebased @mstanleyjones @thaJeztah |
This commit reverts 273eeb8 (moby#26825). For the discussion so far, please refer to moby#28527. Signed-off-by: Akihiro Suda <[email protected]>
[Revert #26825] cli: remove `--mount` from `docker run`
This commit reverts 273eeb8 (moby#26825). For the discussion so far, please refer to moby#28527. Signed-off-by: Akihiro Suda <[email protected]> (cherry picked from commit e6d9b7d) Signed-off-by: Victor Vieux <[email protected]>
This commit reverts 273eeb8 (moby#26825). For the discussion so far, please refer to moby#28527. Signed-off-by: Akihiro Suda <[email protected]>
For those arriving here; After reviewing UX consistency in the client, this feature will be reverted for 1.13 (see #28838, and the discussion on #28527). This feature will return in another form in 1.14
Update: re-implemented in #32251, which is part of Docker 17.05
- What I did
add
--mounttodocker run, which enables the new mount api (#22373) for CLI.- How I did it
Add a
--mountasMountOpt.So user can specify multiple
--mount. (similar todocker service create..)Also, user can mix up
--mountand-vsimultaneously.- How to verify it
- Description for the changelog
cli: add
--mounttodocker run- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Akihiro Suda [email protected]