Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Allow adding rules to cgroup devices.allow on container create/run#22563

Merged
vdemeester merged 3 commits intomoby:mastermoby/moby:masterfrom
mlaventure:cgroup-devicesmlaventure/docker:cgroup-devicesCopy head branch name to clipboard
Feb 1, 2017
Merged

Allow adding rules to cgroup devices.allow on container create/run#22563
vdemeester merged 3 commits intomoby:mastermoby/moby:masterfrom
mlaventure:cgroup-devicesmlaventure/docker:cgroup-devicesCopy head branch name to clipboard

Conversation

@mlaventure
Copy link
Copy Markdown
Contributor

@mlaventure mlaventure commented May 6, 2016

- What I Did

This introduce a new --device-cgroup-rule flag that allow a user to add
one or more entry to the container cgroup device devices.allow

This should hopefully give a solution to issue like the one referred in the #22206 proposal:

  • add a rule to the container cgroup (e.g. 'c 13:* rwm')
  • via udev, execute a script anytime such a device is added.
  • the script should check whether the device should or should not be added to a given container
  • if the device is to be added, the script can run a docker exec to mknod the device into the container

- Note

I will make the required vendoring/engin-api PR once this has been accepted.

- Description for the changelog

  • Add the ability to specify extra rules for a container device cgroup devices.allow mechanism

- A picture of a cute animal (not mandatory but encouraged)


Signed-off-by: Kenfe-Mickael Laventure mickael.laventure@gmail.com

@mlaventure mlaventure changed the title [WIP] Allow adding rules to cgroup devices.allow on container create/run Allow adding rules to cgroup devices.allow on container create/run May 12, 2016
@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented May 23, 2016

I agree with a feature, but naming is confusing I think. Maybe something like device-cgroup-rule? I dunno

@mlaventure
Copy link
Copy Markdown
Contributor Author

@LK4D4 I like the name, thanks! Will update shortly

@thaJeztah
Copy link
Copy Markdown
Member

ping @LK4D4 ptal

@icecrime icecrime added the status/failing-ci Indicates that the PR in its current state fails the test suite label Jun 1, 2016
@mlaventure
Copy link
Copy Markdown
Contributor Author

Added a test

@cpuguy83
Copy link
Copy Markdown
Member

cpuguy83 commented Jun 4, 2016

This seems super low-level (much more so than any other flag we have, I think).

I don't understand the limitations on the devices cgroup, but... it seems like we should be able to address the use case with docker update to deal with adding the device to the whitelist and performing the mknod for the user.

This could also be looked at along with security profiles... some profile option to enable host device update access.

@mlaventure
Copy link
Copy Markdown
Contributor Author

ping @tonistiigi , if I'm not wrong he was against a docker update solution. I'll let him explain his view :)

@tonistiigi tonistiigi removed status/failing-ci Indicates that the PR in its current state fails the test suite status/needs-vendoring labels Sep 15, 2016
@mlaventure mlaventure added status/failing-ci Indicates that the PR in its current state fails the test suite and removed status/failing-ci Indicates that the PR in its current state fails the test suite labels Sep 15, 2016
@tonistiigi
Copy link
Copy Markdown
Member

Design LGTM

@GordonTheTurtle GordonTheTurtle added this to the 1.14.0 milestone Feb 1, 2017
@vdemeester vdemeester added docs/revisit and removed status/needs-attention Calls for a collective discussion during a review session labels Feb 1, 2017

## Specify isolation technology for container (--isolation)

This option is useful in situations where you are running Docker containers on
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.

Why was this section removed?

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.

oh, I see; moved to the other document

@thaJeztah
Copy link
Copy Markdown
Member

@mlaventure looks like you forgot to update the CLI reference with the example; #22563 (comment)

@mlaventure
Copy link
Copy Markdown
Contributor Author

ping @albers I had initially added a basic completion for bash (it's a very old PR), but I think you would do a better job, mind having a second look?

Thanks!

@albers
Copy link
Copy Markdown
Member

albers commented Mar 14, 2017

@mlaventure I don't think this can be improved because the argument contains a space. AFAIK, bash completion does not work inside quoted arguments.

@mlaventure
Copy link
Copy Markdown
Contributor Author

@albers thanks for checking!

dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
Allow adding rules to cgroup devices.allow on container create/run
@hqhq
Copy link
Copy Markdown
Contributor

hqhq commented Aug 1, 2017

Why not improving --device to support something like --device /dev/sdb*:rx than to introduce this option?

@mlaventure
Copy link
Copy Markdown
Contributor Author

@hqhq what you suggest would require to spawn a goroutine to monitor changes to the filesystem and replicate it within the container. But that would also assume that the container has all the tools necessary for this (e.g. mknod) or force it to be there.

Also, maybe the right of the device thus newly created would need to be changed within the container.

It's easier to let people set up their own policy with the tool provided.

@pbelskiy
Copy link
Copy Markdown

pbelskiy commented Jan 29, 2018

  1. How can I use --device-cgroup-rule option by docker-compose?

  2. Also, I created some POC for working with dynamically created USB devices in Docker, does it correct? It works fine, but it seems very ugly:
    https://github.com/pbelskiy/docker-usb-sync

@mlaventure
Copy link
Copy Markdown
Contributor Author

@TH3MIS

  1. I don't think it's supported, you should ask on the compose repository: https://github.com/docker/compose

  2. That looks correct. I don't see the ugliness in it. I'm not fan of adding a whole udev handler in the Docker daemon when there's already a dedicated architecture for udev.

@pbelskiy
Copy link
Copy Markdown

@mlaventure
Why also there is no option to initially add с 189:* rwminto devices.list when create new cgroup for container? I suppose it best solution, but I am new in Docker, and maybe I'm wrong here

@mlaventure
Copy link
Copy Markdown
Contributor Author

@TH3MIS that what the option you're providing does.

@pamelamei
Copy link
Copy Markdown

I think this feature is really helpful.

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.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.