Adds a devadd cli command and a native/lxc backend implementation#6369
Adds a devadd cli command and a native/lxc backend implementation#6369calfonso wants to merge 4 commits intomoby:masterfrom
Conversation
|
This PR is also dependent upon a couple libcontainer PRs being merged and vendored. Those pull requests are: |
|
@calfonso what are the use cases? links to docs or requirements? |
|
Just to add some context of why we want to add a device at runtime... |
|
@shykes thoughts on this? |
|
@calfonso this PR will need documentation added - both to |
* This commit is dependent on several pull requests being merged into docker and libcontainer that expose the devadd and devrm API. moby/moby#6369 docker-archive/libcontainer#6 docker-archive/libcontainer#7 Change-Id: I6dcd7d809027bfe6ddcd9d521e519656a1ad526a
|
@SvenDowideit Thanks for the heads up. I've added a commit for the docs to this PR. |
|
@calfonso you're missing the DCO on the last commit - There is a githook in the CONTRIBUTING.md that will do it for you... |
|
I'm opposed to this. I do not believe volume attach/detach is a useful operation for a container. I feel this is the side effect of trying to shove containers into a VM model. If you want to treat a container as a VM then just use libvirt-lxc. |
|
@ibuildthecloud would you mind elaborating a bit on the lack of usefulness? It is useful to be able to attach storage to a running container in that a service doesn't need to be terminated to attach storage. |
|
I'm curious to see if this set of PR's (including the closed unmerged one in libcontainer) will help @jpetazzo and me do some slightly cool and dubious things with sharing mounts made from inside a container to another container |
|
@SvenDowideit ewindisch has done a bit of research on using libseccomp to do a secure mount, which is not part of this patch set. These patches will enable sharing devices though! |
|
@ewindisch @jpetazzo perhaps we all need to get together sometime soon :) |
|
@SvenDowideit wait, that's totally not the same thing. This dynamically grants access to a device, using the corresponding cgroup. We were working on dynamic bind mounts (or even mounts). Of course, if you want to mount a filesystem sitting on a "real" device, that helps. But that's not what I was working on, sorry! |
|
@jpetazzo yes, i realise its not the same thing - but its all related :) |
|
@calfonso note that #6134 introduces language into the documentation around the security of ephemeral devices being added and not being able to be removed. It would be worth amending that documentation with the ability to 'docker devrm' devices. There would still be security risks dependent on how users manage these device bindings, but this partially addresses those concerns. |
There was a problem hiding this comment.
you'll need to indent this and put newlines around it to make it rendered as code, and atm, we prefix commandlines with $ (dollar space)
|
Docs essentially LGTM |
Co-Authored-By: Ian Main <[email protected]> Docker-DCO-1.1-Signed-off-by: Chris Alfonso <[email protected]> (github: calfonso)
Implement the backend for device add in both native and LXC exec drivers. These both make use of the nsenter_mknod() function added to libcontainer. Co-Authored-By: Chris Alfonso <[email protected]> Docker-DCO-1.1-Signed-off-by: Ian Main <[email protected]> (github: imain)
* Use docker devrm CONTAINER_ID device_path to remove a device Co-Authored-By: Ian Main <[email protected]> Docker-DCO-1.1-Signed-off-by: Chris Alfonso <[email protected]> (github: calfonso)
* Added descriptions and examples for the cli.md and man pages for the following: docker devadd CONTAINER DEVICE docker devrm CONTAINER DEVICE Docker-DCO-1.1-Signed-off-by: Chris Alfonso <[email protected]> (github: calfonso)
|
I talked with the other maintainers about this and it is something that we want to get in. We are just worried about the UI for the feature. If we go the route of We can take what you have now with the changes to libcontainer and lxc and get these merged in but we would like it if you could propose some alternatives to the UI ( cli and API ) so that the command set does not explode when we start adding more ways to modify the container. Does this sound ok with you? |
|
@crosbymichael For the UI, what do you think about introducing something like the following? docker update CONTAINER --action ACTION --args ACTION_ARGS and have the API have something similar? For device adding/removing it would look like: docker update 54b8808d05cf --action device-add --args /dev/loop0 Re merging libcontainer the lxc patch, that requires the C go patch for nsenter Mknod ( docker-archive/libcontainer#6 ) that you had requested be reimplemented in a more generic way as well, so we're working through that. |
|
@crosbymichael after chatting with @calfonso this morning, perhaps a general foundation command like And this way, the API and UI can stay generic for a number of other features. Look okay? |
|
@vbatts I like that, as it prevents the UI from 'exploding' and keeps the road open for additional modifications to existing containers (e.g. Dynamically add/remove links). Not too fond on the string notation of the actual action ( |
|
@thaJeztah clunky, maybe, but same as existing flags like |
|
@vbatts you're right. So, better clunky, but consistent than slick and inconsistent. You have my vote FWIW :) |
|
update or modify sounds good to me. For an API request I was thinking about something like: POST /containers/<name>/{update|modify}
{
"type": "device",
"values": {
"add": "/dev/loop0"
}
}values just being a What do you think? |
|
I like modify better than update. I like the API. Any other thoughts from anyone before we get started? |
|
However, if renaming containers will be implemented in the future, I think the endpoint of the API should be; i.e. Use the container id, not its name. This is a bit less convenient, but consistent with other parts of the API as well. Finally, shouldn't the API call use |
|
@thaJeztah Yes, I'll use PUT |
|
Unless @crosbymichael disagrees, because IANTM, just a friendly visitor 😄 |
|
@thaJeztah id and name can be used interchangeably so the endpoint will accept both. PUT sounds +1 @calfonso maybe we need to change the map from {
"type": "device",
"values": {
"add": ["/dev/loop0", "/dev/loop1"]
}
}ping @vieux |
|
Maybe even one step further; to allow batch-updating multiple properties in future; |
|
I would personally like these features, but some of the security discussion here concerns me. |
|
@timthelion - there would be a timing attack possible, but that's still better than being outright unable to remove the device nodes. |
|
Closing this has there is a better implementation opened by the same authors. |
|
Hi, @calfonso , May I ask you a question, How can I install docker with source code from https://github.com/calfonso/docker/tree/docker_modify which has the ability to add/remove device to running container? |
This commit is dependent upon #6134 being merged