Skip to content

Do not hide user provided network mounts [v2] - #14613

Merged
cpuguy83 merged 1 commit into
moby:masterfrom
stefanberger:nohidevols2
Jul 22, 2015
Merged

cpuguy83 merged 1 commit into
moby:masterfrom
stefanberger:nohidevols2

Conversation

@stefanberger

Copy link
Copy Markdown
Contributor

Prevent the docker daemon from mounting the created network files over
those provided by the user via -v command line option. This would otherwise
hide the one provide by the user.
The benefit of this is that a user can provide these network files using the
-v command line option and place them in a size-limited filesystem.

Signed-off-by: Stefan Berger [email protected]

@cpuguy83

Copy link
Copy Markdown
Member

Looks like it needs a gofmt.

@stefanberger

Copy link
Copy Markdown
Contributor Author

Fixed.

@calavera

Copy link
Copy Markdown
Contributor

can we do this when we create the mount points for those resources rather than afterwards?

@stefanberger

Copy link
Copy Markdown
Contributor Author

@calavera Can you point me to the code where the mount points are created ? Obviously I am map'ing the bind-mounts when we traverse them and then us the map to fix up the file to be mounted to the mount points.

@calavera

Copy link
Copy Markdown
Contributor

Yes, but we're not removing those mount points from the collection and we're going to end up adding duplicated destinations in https://github.com/docker/docker/blob/master/daemon/container.go#L1090-L1120. I wonder if we can combine both somehow.

@ewindisch

Copy link
Copy Markdown
Contributor

addresses #13152

@stefanberger

Copy link
Copy Markdown
Contributor Author

@calavera @ewindisch Should the user provide the content for these files or docker daemon? If the files are set earlier in the container structure (container.HostsPath for example) then the content is overwritten by the daemon.
I set them now in this code here https://github.com/docker/docker/blob/master/daemon/container_unix.go#L366-L403 and removed their entries from the container,MountPoints, so they only appear once. However, their content is then overwritten by the daemon, which may not be the intention.

@stefanberger

Copy link
Copy Markdown
Contributor Author

@calavera

Copy link
Copy Markdown
Contributor

oh man, sorry for all the back and forth. I think this PR is more correct, but it requires a small change. In the setupMounts function we don't want to append the exec.Mount struct to the array if the destination is one of those paths. Otherwise we're going to try to mount the same destination twice.

At the end, right now we have something like:

[
   exec.Mount{Destination: "/etc/resolv.conf", Source: "/foo"...},
   exec.Mount{Destination: "/bar", Source: "/bar"...},
   exec.Mount{Destination: "/etc/resolv.conf", Source: container.ResolvConfPath...},
]

We want to not add the first exec.Mount. So, inside the loop for _, m := range container.MountPoints we need to check for those destinations.

@stefanberger

Copy link
Copy Markdown
Contributor Author

@calavera Have a look now.

@calavera

Copy link
Copy Markdown
Contributor

I like it!

@stefanberger what do you think about adding an integration test to make sure this works?

Comment thread daemon/volumes_linux.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

that == false can be better expressed with !container.trySetNetworkMount.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will changes this.
And since it seem it will make make it 'in', I'll add test cases as well. Thanks

@stefanberger
stefanberger force-pushed the nohidevols2 branch 6 times, most recently from 1ef9100 to 5cce424 Compare July 21, 2015 01:13
@stefanberger

Copy link
Copy Markdown
Contributor Author

@calavera For some reason I cannot run 'make test' on my machine. Step 2 fails for me.

I now added a test case.

It is difficult to apply the 'read-only' parameter passed via -v to those individual files. In this aspect the previous PR (https://github.com/docker/docker/pull/14529/files) I think would allow the handling of this in a more elegant way.

@calavera

Copy link
Copy Markdown
Contributor

Tests seem to pass, but the code needs to be rebased.

@stefanberger

Copy link
Copy Markdown
Contributor Author

Rebased.

@stefanberger
stefanberger force-pushed the nohidevols2 branch 5 times, most recently from 2d1b3d4 to 1f71dc8 Compare July 22, 2015 11:11
@estesp

estesp commented Jul 22, 2015

Copy link
Copy Markdown
Contributor

LGTM

Comment thread integration-cli/docker_cli_run_test.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry I'm being a stickler here, but there is no reason to use dockerCmdWithError here.
dockerCmd checks the error and fails the test automatically.
So unless the error needs to be inspected you should use dockerCmd.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agreed, I think we already moved all other tests to dockerCmd.

Prevent the docker daemon from mounting the created network files over
those provided by the user via -v command line option. This would otherwise
hide the one provide by the user.
The benefit of this is that a user can provide these network files using the
-v command line option and place them in a size-limited filesystem.

Signed-off-by: Stefan Berger <[email protected]>
@estesp

estesp commented Jul 22, 2015

Copy link
Copy Markdown
Contributor

Looks like this is updated @cpuguy83 , and amazingly, CI is green :)

@cpuguy83

Copy link
Copy Markdown
Member

LGTM

@stefanberger make sure you ping us in the comments when you make updates!

cpuguy83 added a commit that referenced this pull request Jul 22, 2015
Do not hide user provided network mounts [v2]
@cpuguy83
cpuguy83 merged commit d106a2e into moby:master Jul 22, 2015
@stefanberger

Copy link
Copy Markdown
Contributor Author

Thanks.

@ewindisch

Copy link
Copy Markdown
Contributor

@stefanberger how does this work with the ':ro' specifier (-v file:/etc/hosts:ro)? What about if you do 'run --read-only'?

@stefanberger

Copy link
Copy Markdown
Contributor Author

@ewindisch See above: "It is difficult to apply the 'read-only' parameter passed via -v to those individual files. In this aspect the previous PR (https://github.com/docker/docker/pull/14529/files) I think would allow the handling of this in a more elegant way."

@ewindisch

Copy link
Copy Markdown
Contributor

@stefanberger right, I saw that. I think this breaks user expectations of what ':ro' should do. Also, --read-only will apply here when it does not apply to other volumes. Perhaps simply add new fields adjacent to the path variables which indicates if these should be mounted rw/ro?

@stefanberger

Copy link
Copy Markdown
Contributor Author

Sounds good to me. I'll add two test cases.

@thaJeztah

Copy link
Copy Markdown
Member

@ewindisch @stefanberger should I apply the "impact/changelog" label here? If I understand correctly, there's a change in behavior here that people should be aware of (and needs a mention in the changelog)?

@ewindisch

Copy link
Copy Markdown
Contributor

@thaJeztah it's a new feature, so it could be useful for users to know of it. It doesn't otherwise change behavior. It allows specifying '-v somepath:/etc/hosts' which wasn't working previously.

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.

7 participants